ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Алгоритмы и Структуры Данных > задача:


42. Money Sums

Задачи сборника

• 34. Maximum Subarray Sum
• 35. Stick Lengths
• 36. Missing Coin Sum
• 37. Collecting Numbers
• 38. Playlist
• 39. Towers
• 40. Traffic Lights
• 41. Finding Borders
• 42. Money Sums
• 43. Finding Periods
• 44. Minimal Rotation
• 45. Static Range Sum Queries
• 01. Автобус в Джал
• 03. Новый язык программирования
• 05. Trailing Zeros
• 17. Number Spiral
• 23. Apple Division

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Сложность Альфа


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