#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, l, left, right, up, down;
  char str[110000];
  while (scanf("%d", &n) != EOF) {
    scanf("%s", str);
    left = right = up = down = 1;
    for (i = 0; i < n; i++) {
      if (str[i] == '1' || str[i] == '2' || str[i] == '3') up = 0;
      if (str[i] == '1' || str[i] == '4' || str[i] == '7' || str[i] == '0')
        left = 0;
      if (str[i] == '7' || str[i] == '9' || str[i] == '0') down = 0;
      if (str[i] == '6' || str[i] == '9' || str[i] == '3' || str[i] == '0')
        right = 0;
    }
    if (down || up || left || right)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
