#include <bits/stdc++.h>
using namespace std;
char s[15];
int main() {
  int n;
  bool f, f1, f2, f3, f4;
  while (~scanf("%d", &n)) {
    scanf("%s", s);
    f = f1 = f2 = f3 = f4 = 1;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1' || s[i] == '2' || s[i] == '3') f1 = false;
      if (s[i] == '1' || s[i] == '4' || s[i] == '7') f2 = false;
      if (s[i] == '7' || s[i] == '0' || s[i] == '9') f3 = false;
      if (s[i] == '3' || s[i] == '6' || s[i] == '9') f4 = false;
      if (s[i] == '0') f = false;
    }
    if (!f && !f1)
      printf("YES\n");
    else if (f1 || f2 || f3 || f4)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
