#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = "YES\n";
  for (int i = 0; i < n; ++i) {
    a[s[i] - '0']++;
  }
  if ((a[7] == 0 && a[9] == 0 && a[0] == 0) ||
      (a[1] == 0 && a[4] == 0 && a[7] == 0 && a[0] == 0) ||
      (a[3] == 0 && a[6] == 0 && a[9] == 0 && a[0] == 0) ||
      (a[1] == 0 && a[2] == 0 && a[3] == 0))
    ans = "NO\n";
  cout << ans;
}
