atcoder#CODEFESTIVAL2016EXB. Exact Payment

Exact Payment

Score : 15001500 points

Problem Statement

The currency used in Takahashi Kingdom is Myon. There are 11-, 1010-, 100100-, 10001000- and 1000010000-Myon coins, and so forth. Formally, there are 10n10^n-Myon coins for any non-negative integer nn.

There are NN items being sold at Ex Store. The price of the ii-th (1iN)(1 \leq i \leq N) item is AiA_i Myon.

Takahashi is going to buy some, at least one, possibly all, of these NN items. He hates receiving change, so he wants to bring coins to the store so that he can pay the total price without receiving change, no matter what items he chooses to buy. Also, since coins are heavy, he wants to bring as few coins as possible.

Find the minimum number of coins he must bring to the store. It can be assumed that he has an infinite supply of coins.

Constraints

  • 1N20,0001 \leq N \leq 20,000
  • 1Ai10121 \leq A_i \leq 10^{12}

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 ...... ANA_N

Output

Print the minimum number of coins Takahashi must bring to the store, so that he can pay the total price without receiving change, no matter what items he chooses to buy.

3
43 24 37
16

There are seven possible total prices: 24,37,43,61,67,80,24, 37, 43, 61, 67, 80, and 104104. With seven 11-Myon coins, eight 1010-Myon coins and one 100100-Myon coin, Takahashi can pay any of these without receiving change.

5
49735011221 970534221705 411566391637 760836201000 563515091165
105