#include <bits/stdc++.h>
using namespace std;
long long n, m, a[10];
char ch;
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> ch, a[ch - 48]++;
  if ((a[1] + a[2] + a[3] > 0 && a[1] + a[4] + a[7] > 0 &&
       a[3] + a[6] + a[9] > 0 && a[7] + a[0] + a[9] > 0) ||
      (a[1] + a[2] + a[3] > 0 && a[0] > 0))
    cout << "YES";
  else
    cout << "NO";
}
