Global Security Systems Inc. is developing a new authentication system for high-security applications. The security team has identified that traditional PIN codes are vulnerable when users choose patterns with excessive consecutive digit repetitions (like 1111, 2222, or 000).
To enhance security, the team is designing a new PIN validation system with the following requirements:
PINs must be exactly digits long, using digits from to
For each digit (where ranges from to ), the system enforces a maximum limit t_k on how many times that digit can appear consecutively
PINs cannot start with (to maintain standard numeric format)
For example, if t_1 = 2, then the PIN "11234" would be valid, but "11123" would be invalid if it contained three consecutive 1s anywhere.
The security analysts need to determine: Given the PIN length and the consecutive repetition limits t_k for each digit , how many valid PINs can be generated under these security constraints?
This analysis helps the security team:
Evaluate the strength of the PIN space
Balance security requirements with user convenience
Estimate the difficulty of brute-force attacks
The first line contains the PIN length (1 \leq n \leq 9).
The second line contains ten integers: t_0, t_1, …, t_9 (0 \leq t_k \leq 9), representing the maximum number of consecutive occurrences allowed for each digit.
Output a single integer representing the total number of valid PINs that satisfy all security constraints.
Example 1