#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 10

int n, t[MAXN];
VI getDigits(ll v) {
  VI res;
  while (v > 0) {
    res.push_back(v % 10);
    v /= 10;
  }
  return res;
}
bool invalid(VI &ds) {
  for (int i = 0; i < ds.size(); i += 2) {
    int v = ds[i] + (i + 1 < ds.size() ? ds[i + 1] * 10 : 0);
    if (v >= t[i / 2]) return true;
  }
  return false;
}
int main() {
  cin >> n;
  REP(i,0,n) cin >> t[i];
  ll maxv = 0;
  ll ans = 0;
  REP(i,0,n) maxv = maxv * 100 + t[i] - 1;
  reverse(t, t + n);
  for (ll v = 1; v <= maxv; v++) {
    VI ds = getDigits(v);
    if (invalid(ds)) continue;
    bool ok = true;
    REP(i,0,ds.size()) {
      VI nds = ds;
      nds.erase(nds.begin() + i);
      if (invalid(nds)) {
        ok = false;
        break;
      }
    }
    if (!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
