#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7, N = 100000 + 9;
const long long INF = -1ULL / 2;
int n, ngang[5], doc[5], cntngang, cntdoc;
string s;
map<char, int> kcn, kcd, fof;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  kcn['1'] = kcn['2'] = kcn['3'] = 1;
  kcn['7'] = kcn['8'] = kcn['9'] = 3;
  kcd['1'] = kcd['4'] = kcd['7'] = 1;
  kcd['3'] = kcd['6'] = kcd['9'] = 3;
  kcn['0'] = kcd['0'] = 4;
  for (int i = 0; i < n; ++i) {
    ++ngang[kcn[s[i]]];
    ++doc[kcd[s[i]]];
    ++fof[s[i]];
  }
  for (int i = 1; i < 4; ++i) {
    if (ngang[i] >= 1) ++cntngang;
    if (doc[i] >= 1) ++cntdoc;
  }
  if (cntngang >= 2 && cntdoc >= 2 &&
      (fof['0'] > 0 || fof['7'] > 0 || fof['9'] > 0))
    cout << "YES";
  else if (cntngang == 3)
    cout << "YES";
  else if (ngang[1] > 0 && ngang[4] > 0)
    cout << "YES";
  else
    cout << "NO";
  cout << '\n';
}
