#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i;
  char a[11];
  scanf("%d", &n);
  int f = 0;
  scanf("%s", a);
  for (i = 0; i < n; i++)
    if (a[i] == '0') f = 1;
  if (f == 1) {
    for (i = 0; i < n; i++)
      if (a[i] == '1' || a[i] == '2' || a[i] == '3') {
        printf("YES\n");
        return 0;
      }
    printf("NO");
  } else {
    int c1, c2, c3, c4;
    c1 = c2 = c3 = c4 = 0;
    for (i = 0; i < n; i++) {
      if (a[i] == '1' || a[i] == '2' || a[i] == '3') c1 = 1;
      if (a[i] == '3' || a[i] == '6' || a[i] == '9') c2 = 1;
      if (a[i] == '7' || a[i] == '9') c3 = 1;
      if (a[i] == '1' || a[i] == '4' || a[i] == '7') c4 = 1;
    }
    if (c1 && c2 && c3 && c4) {
      printf("YES");
    } else
      printf("NO");
  }
  return 0;
}
