#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
using namespace std;
vector<int> edges[210000];
bool vis[210000];
int ans[210000];
int main() {
  int n;
  cin >> n;
  int a[10];
  for (int i = 0; i < (int)n; i++) {
    char c;
    cin >> c;
    a[i] = c - '0';
  }
  bool b[4];
  for (int i = 0; i < (int)4; i++) b[i] = 0;
  for (int i = 0; i < (int)n; i++) {
    int d = a[i];
    if (d == 1 || d == 4 || d == 7 || d == 0) b[0] = 1;
    if (d == 7 || d == 0 || d == 9) b[1] = 1;
    if (d == 0 || d == 9 || d == 6 || d == 3) b[2] = 1;
    if (d == 1 || d == 2 || d == 3) b[3] = 1;
  }
  for (int i = 0; i < (int)4; i++)
    if (!b[i]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
