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