#include <bits/stdc++.h>
using namespace std;
int N;
unsigned int input;
int arr[10];
int flag;
int searchval(int val) {
  for (int i = 0; i < N; i++)
    if (arr[i] == val) {
      return 1;
    }
  return 0;
}
int searchtwoval(int val1, int val2) {
  int counter = 0;
  for (int i = 0; i < N; i++)
    if (arr[i] == val1) {
      counter++;
      break;
    }
  for (int i = 0; i < N; i++)
    if (arr[i] == val2) {
      counter++;
      break;
    }
  if (counter == 2) return 1;
  return 0;
}
void solvecase() {
  for (int i = 0; i < N; i++) {
    if (arr[i] == 1) {
      if (searchval(0)) {
        flag = 1;
        break;
      } else if (searchval(9)) {
        flag = 1;
        break;
      } else if (searchtwoval(6, 7)) {
        flag = 1;
        break;
      }
    } else if (arr[i] == 2) {
      if (searchval(0)) {
        flag = 1;
        break;
      } else if (searchtwoval(4, 9)) {
        flag = 1;
        break;
      } else if (searchtwoval(6, 7)) {
        flag = 1;
        break;
      } else if (searchtwoval(7, 9)) {
        flag = 1;
        break;
      }
    } else if (arr[i] == 3) {
      if (searchval(7)) {
        flag = 1;
        break;
      } else if (searchval(0)) {
        flag = 1;
        break;
      } else if (searchtwoval(4, 9)) {
        flag = 1;
        break;
      }
    }
  }
}
void readcase() {
  flag = 0;
  while (cin >> N) {
    cin >> input;
    for (int i = 0; i < N; i++) {
      arr[i] = input % 10;
      input = input / 10;
    }
    solvecase();
  }
}
void printcase() {
  if (flag == 1)
    printf("YES\n");
  else
    printf("NO\n");
}
int main() {
  readcase();
  printcase();
}
