#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int p = 0, q = 0, t = 0, r = 0, l = 0;
  for (long long int i = 0; s[i] != '\0'; i++) {
    if (s[i] == '1' || s[i] == '2' || s[i] == '3') {
      p = 1;
    }
    if (s[i] == '1' || s[i] == '4' || s[i] == '7') {
      r = 1;
    }
    if (s[i] == '7' || s[i] == '0' || s[i] == '9') {
      q = 1;
    }
    if (s[i] == '3' || s[i] == '6' || s[i] == '9') {
      t = 1;
    }
    if (s[i] == '0') {
      l = 1;
    }
  }
  if (q == 1 && p == 1 && r == 1 && t == 1) {
    cout << "YES" << endl;
  } else if (l == 1 && p == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
