// Arup Guha
// 4/24/2021
// Solution to 2021 NADC Problem A: Alien Microwave

import java.util.*;

public class a {

	public static void main(String[] args) {
	
		// Get input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int[] lim = new int[n];
		for (int i=0; i<n; i++)
			lim[i] = stdin.nextInt();
			
		// prod[i] is how many ways to fill in the future items.
		long[] prod = new long[n];
		prod[n-1] = 1;
		for (int i=n-2; i>=0; i--)
			prod[i] = prod[i+1]*lim[i+1];
	
		// Weird DP table. 1st index is # of errors, second is which entry we are on.
		// third is which "unit" we are ending on. We store the # of entries that end
		// in that state.
		long[][][] dp = new long[2][n][];
		for (int i=0; i<2; i++)
			for (int j=0; j<n; j++)
				dp[i][j] = new long[lim[j]];
				
		// With only 1 unit of measurement, everything is valid.
		for (int i=0; i<lim[0]; i++)
			dp[0][0][i] = 1;
		
		// i is the unit of measurement we care about.
		for (int i=1; i<n; i++) {
		
			// Ending value for this round.
			for (int y=0; y<lim[i]; y++) {
			
				// Ending for previous round.
				for (int x=0; x<lim[i-1]; x++) {
			
					// If we can get our single error here, add to error code.
					if (error(x, y, lim[i-1], lim[i]))
						dp[1][i][y] += dp[0][i-1][x];
						
					// Add these into ones that can't have errors.
					else
						dp[0][i][y] += dp[0][i-1][x];
				}
			}
		}
		
		// Add up all bad values times what we can fill in the future.
		long res = 0;
		for (int i=0; i<n; i++) 
			for (int j=0; j<lim[i]; j++)
				res += (dp[1][i][j]*prod[i]);
		System.out.println(res);
	}
	
	// returns true iff an error could be caused between entries v1 and v2 with
	// respective limits lim1 and lim2.
	public static boolean error(int v1, int v2, int lim1, int lim2) {
		
		// Delete tens digit of v2.
		int alt1 = (v1%10)*10 + v2%10;
		if (alt1 >= lim2) return true;
		
		// Delete ones digit of v2.
		int alt2 = (v1%10)*10 + v2/10;
		if (alt2 >= lim2) return true;
		
		// We're good.
		return false;
	}
}