#include <bits/stdc++.h>
using namespace std;
bool compa(int i, int j) { return i > j; }
long long int power(long long int a, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2) {
    long long int d1 = power(a, n / 2);
    return d1 * d1 * a;
  } else {
    long long int d1 = power(a, n / 2);
    return d1 * d1;
  }
}
int find_pivot(int a[], int l, int r) {
  while (l < r) {
    int mid = (l + r) / 2;
    if (a[l] > a[l + 1]) {
      return l;
    } else if (a[r] > a[r + 1])
      return r;
    else if (a[mid] > a[mid + 1]) {
      return mid;
    } else if (a[mid] > a[r]) {
      l = mid + 1;
      cout << "l " << l;
    } else if (a[mid] < a[r]) {
      r = mid - 1;
      cout << "r " << r;
    }
  }
  return -1;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool ans[4];
  for (int i = 0; i < 4; i++) ans[i] = true;
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == '1') {
      ans[0] = false;
      ans[2] = false;
    }
    if (s[i] == '2') {
      ans[0] = false;
    }
    if (s[i] == '3') {
      ans[0] = false;
      ans[3] = false;
    }
    if (s[i] == '4') {
      ans[2] = false;
    }
    if (s[i] == '6') {
      ans[3] = false;
    }
    if (s[i] == '7') {
      ans[1] = false;
      ans[2] = false;
    }
    if (s[i] == '9') {
      ans[1] = false;
      ans[3] = false;
    }
    if (s[i] == '0') {
      ans[1] = false;
      ans[2] = false;
      ans[3] = false;
    }
  }
  if (ans[0] || ans[1] || ans[2] || ans[3])
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
