#include <bits/stdc++.h>
using namespace std;
int N, avl = 15;
int a[10];
int moves[] = {1, 12, 14, 6, 13, 15, 7, 9, 15, 3};
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  while (N--) {
    char x;
    cin >> x;
    ++a[x - '0'];
  }
  for (int i = 0; i < 10; ++i)
    if (a[i]) avl &= moves[i];
  cout << (!avl ? "YES\n" : "NO\n");
  return 0;
}
