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