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