PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000043. Các tổng tiền có thể tạo (Money Sums)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Các tổng tiền có thể tạo (Money Sums)

Money Sums

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

You have nn individual coins. Coin ii has value aia_i. Each coin can be used at most once; equal-valued coins still count as separate coins. Consider all selections containing at least one coin and sum the selected values. List every distinct positive attainable sum in increasing order.

Input

The first line contains nn. The next line contains nn coin values aia_i.

Output

Print the number kk of distinct sums on the first line, then the kk positive sums in increasing order on the next line.

Subtasks

The independent scoring groups have the following complete constraints:

  • Subtask 1 (20%): 1≤n≤151\le n\le15, 1≤ai≤201\le a_i\le20.
  • Subtask 2 (30%): 1≤n≤501\le n\le50, 1≤ai≤1001\le a_i\le100.
  • Subtask 3 (50%): 1≤n≤1001\le n\le100, 1≤ai≤10001\le a_i\le1000.

Examples

Input

4
4 2 5 2

Output

9
2 4 5 6 7 8 9 11 13

Explanation

From coins 4,2,5,24,2,5,2, the distinct positive reachable sums are 2,4,5,6,7,8,9,11,132,4,5,6,7,8,9,11,13. There are 99 of them and they must be printed in increasing order.