"Peace"
One of the recent discoveries by the Russian space station "Mir" involves decoding a message, believed to be from intelligent extraterrestrial civilizations beyond our galaxy.
The decoded message consists of a sequence of long numbers, each containing n digits ranging from 0 to 9. An intriguing finding from the research is that within each number, the digit 0 never appears consecutively more than t_0 times, the digit 1 no more than t_1 times, and so forth for each digit. Additionally, multi-digit numbers do not begin with the digit 0. Earth scientists hypothesize that this sequence represents the language of a distant planet, with these numbers functioning as words do for humans.
Your task is to assist the scientists in determining how many such "words" this language can have, given their length n, and the maximum allowable consecutive occurrences t_k for each digit k from 0 to 9.
Input
The first line of the input contains the length of the "words" n (1 ≤ n ≤ 9). The second line provides ten integers – the values t_0, t_1, … , t_9 (0 ≤ t_0 ≤ 9).
Output
Output a single number, representing the total number of "words" in the dictionary of these intelligent extraterrestrial civilizations.