#include <bits/stdc++.h>
using namespace std;
int n;
int u, d, l, r;
int i;
char a[105];
bool pd(int num) {
  if (a[i] == num + '0') return 1;
  return 0;
}
int main() {
  cin >> n;
  cin >> a + 1;
  for (i = 1; i <= n; i++) {
    if (pd(0)) d = r = l = 1;
    if (pd(1) || pd(2) || pd(3)) u = 1;
    if (pd(1) || pd(4) || pd(7)) l = 1;
    if (pd(3) || pd(6) || pd(9)) r = 1;
    if (pd(7) || pd(9)) d = 1;
  }
  if (u * d * l * r)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
