#include <bits/stdc++.h>
using namespace std;
int n;
char num[20];
bool b[10];
int main() {
  cin >> n >> num;
  for (int i = 0; i < strlen(num); i++) {
    b[num[i] - '0'] = true;
  }
  if ((b[1] || b[2] || b[3]) && (b[0] || b[1] || b[4] || b[7]) &&
      (b[3] || b[6] || b[9] || b[0]) && (b[7] || b[9] || b[0]))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
