Hide

Problem A
Alien Microwave

A standard microwave is operated by entering the cooking time as a string in the form of hhmmss, where hh, mm, and ss are two-digit integers less than $24$, $60$, and $60$, respectively. Leading zeros in the string hhmmss are omitted. For example, the cooking time of $3$ minutes is entered as 300, though 0300 or 00300 is also accepted.

When any of hh, mm, or ss exceeds the limit, the microwave will not accept it as a valid cooking time and gives an error. For example, 75 is not accepted, nor is 240000. Note that for the purpose of this problem, we assume that zero seconds of cooking time (represented by a sequence of zero or more 0’s) is valid.

Sometimes, one might make a mistake by omitting a digit while entering the cooking time. For example, while entering 1030 ($10$ minutes and $30$ seconds), omitting the digit 3 turns the input time into 100 ($1$ minute) instead. Omitting the digit 1 turns it into 030 ($30$ seconds). In this case, omitting any of the four digits will still make the resulting string a valid cooking time. However, some other strings, while valid cooking times themselves, can become invalid when exactly one of the digits is omitted. For example, 1700 ($17$ minutes) becomes invalid if either of the zeros is omitted. Such strings are called Error-Prone cooking times.

Now, imagine some extraterrestrial planet, on which a standard microwave is operated by a string in the form $a_1a_2a_3 \ldots a_ n$, where each of $a_1$, $a_2$, …, $a_ n$ is a two-digit non-negative integer (somehow they also use base $10$) less than limits $t_1$, $t_2$, …, $t_ n$, respectively. The rules of valid and invalid cooking time still hold.

Given limits $t_1$, $t_2$, …, $t_ n$, find the number of Error-Prone cooking times. Note that leading zeros don’t change the cooking time, so a time specification like 066 is the same as 66, and should not be counted twice. Also note that $0$ is a legitimate cooking time.


Input

The first line of input contains an integer $n$ ($1 \le n \leq 9$), which is the number of time types in the alien time scheme.

Each of the next $n$ lines contains an integer $t_ i$ ($1 \le t_ i \le 100$), which is the number of partitions in the $i^{th}$ time type in the alien scheme.

Output

Output a single integer, which is the number of Error-Prone cooking times without leading zeros.

Sample Input 1 Sample Output 1
3
24
60
60
51840

Please log in to submit a solution to this problem

Log in