#include <bits/stdc++.h>
using namespace std;
int f[4];
void qu(char d) {
  if (d == '0') {
    f[1] = 0;
    f[2] = 0;
    f[3] = 0;
  } else if (d == '1') {
    f[0] = 0;
    f[3] = 0;
  } else if (d == '2')
    f[0] = 0;
  else if (d == '3') {
    f[0] = 0;
    f[1] = 0;
  } else if (d == '4')
    f[3] = 0;
  else if (d == '6')
    f[1] = 0;
  else if (d == '7') {
    f[2] = 0;
    f[3] = 0;
  } else if (d == '9') {
    f[1] = 0;
    f[2] = 0;
  }
}
int ss() {
  for (int i = 0; i < 4; i++)
    if (f[i] == 1) return 1;
  return 0;
}
int main() {
  int n, i;
  char c[10];
  while (cin >> n) {
    f[0] = 1;
    f[1] = 1;
    f[2] = 1;
    f[3] = 1;
    for (i = 0; i < n; i++) {
      cin >> c[i];
      qu(c[i]);
    }
    if (ss())
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
