#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, int> mapdown, mapup, mapleft, mapright;
  char keys[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  int n, count1 = 0, count2 = 0, count3 = 0, count4 = 0;
  char str[15];
  mapdown.clear();
  mapup.clear();
  mapleft.clear();
  mapright.clear();
  scanf("%d", &n);
  scanf("%s", str);
  for (int i = 0; i < 10; i++) {
    char c = keys[i];
    if (keys[i] == '7' || keys[i] == '0' || keys[i] == '9') {
      mapdown.insert(make_pair(c, 0));
    } else {
      mapdown.insert(make_pair(c, 1));
    }
  }
  for (int i = 0; i < 10; i++) {
    if (keys[i] == '1' || keys[i] == '2' || keys[i] == '3')
      mapup.insert(make_pair(keys[i], 0));
    else
      mapup.insert(make_pair(keys[i], 1));
  }
  for (int i = 0; i < 10; i++) {
    if (keys[i] == '3' || keys[i] == '6' || keys[i] == '9' || keys[i] == '0')
      mapright.insert(make_pair(keys[i], 0));
    else
      mapright.insert(make_pair(keys[i], 1));
  }
  for (int i = 0; i < 10; i++) {
    if (keys[i] == '1' || keys[i] == '4' || keys[i] == '7' || keys[i] == '0')
      mapleft.insert(make_pair(keys[i], 0));
    else
      mapleft.insert(make_pair(keys[i], 1));
  }
  for (int i = 0; i < n; i++) {
    if (mapdown[str[i]] != 0) count1++;
  }
  for (int i = 0; i < n; i++) {
    if (mapup[str[i]] != 0) count2++;
  }
  for (int i = 0; i < n; i++) {
    if (mapleft[str[i]] != 0) count3++;
  }
  for (int i = 0; i < n; i++) {
    if (mapright[str[i]] != 0) count4++;
  }
  if (count1 == n || count2 == n || count3 == n || count4 == n)
    printf("NO");
  else
    printf("YES");
  return 0;
}
