#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 10005;
const int MOD = 1000000;
const int INF = 0x3f3f3f3f;
int n, m;
char s[N];
int u = 1, d = 1, l = 1, r = 1;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') d = l = r = 0;
    if (s[i] == '1') u = l = 0;
    if (s[i] == '2') u = 0;
    if (s[i] == '3') u = r = 0;
    if (s[i] == '4') l = 0;
    if (s[i] == '6') r = 0;
    if (s[i] == '7') d = l = 0;
    if (s[i] == '9') d = r = 0;
  }
  if (u || d || l || r)
    puts("NO");
  else
    puts("YES");
  return 0;
}
