#include <bits/stdc++.h>
int vis[220], q[220][220];
int sum = 0;
using namespace std;
int main() {
  int a, i;
  char q[220];
  int w[10];
  while (~scanf("%d", &a)) {
    memset(w, 0, sizeof(w));
    scanf("%s", q);
    for (i = 0; i < a; i++) {
      w[q[i] - '0']++;
    }
    if ((w[2] != 0 && w[0] != 0) || (w[1] != 0 && w[9] != 0) ||
        (w[3] != 0 && w[7] != 0) || (w[3] != 0 && w[0] != 0) ||
        (w[1] != 0 && w[0] != 0) || (w[2] != 0 && w[4] != 0 && w[9] != 0) ||
        (w[2] != 0 && w[6] != 0 && w[7] != 0) ||
        (w[3] != 0 && w[4] != 0 && w[9] != 0) ||
        (w[1] != 0 && w[6] != 0 && w[7] != 0) ||
        (w[7] != 0 && w[2] != 0 && w[9] != 0)) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
