#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;

typedef long long ll;

int l[9];
int n;
ll dp[100];
ll ndp[100];
int main() {
  cin >> n;
  ll tot = 1;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    tot *= l[i];
  }
  for(int i = 0; i < 100; i++) {
    if(i < l[n-1]) dp[i]++;
  }
  for(int i = n-2; i >= 0; i--) {
    memset(ndp, 0, sizeof(ndp));
    for(int b = 0; b < l[i+1]; b++) {
      for(int a = 0; a < l[i]; a++) {
        bool good = true;
        good &= 10 * (a%10) + (b%10) < l[i+1];
        good &= 10 * (a%10) + (b/10) < l[i+1];
        if(good) {
          ndp[a] += dp[b];
        }
      }
    }
    memcpy(dp, ndp, sizeof(dp));
  }
  cout << tot - accumulate(dp, dp+100, 0LL) << "\n";
}