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