HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


Money Sums

Section problems

• Missing Number
• Weird Algorithm
• Creating Strings
• Josephus Queries
• Increasing Array
• Distinct Numbers
• Towers
• Playlist
• Money Sums
• Apartments
• Ferris Wheel
• Stick Lengths
• Traffic Lights
• Concert Tickets
• Finding Borders
• Finding Periods
• Minimal Rotation

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Alpha


You have n coins with certain values. Your task is to find all money sums you can create using these coins.

Input

The first input line has an integer n: the number of coins.

The next line has n integers x1,x2,…,xn: the values of the coins.

Output

First print an integer k: the number of distinct money sums. After this, print all possible sums in increasing order.

Constraints
1≤n≤100
1≤xi≤1000

Example
Input:
4
4 2 5 2

Output:
9
2 4 5 6 7 8 9 11 13


Для отправки решений необходимо выполнить вход.

www.contester.ru