While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way:

<image>

Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider finger movements as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number "586" are the same as finger movements for number "253":

<image> <image>

Mike has already put in a number by his "finger memory" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?

Input

The first line of the input contains the only integer n (1 ≤ n ≤ 9) — the number of digits in the phone number that Mike put in.

The second line contains the string consisting of n digits (characters from '0' to '9') representing the number that Mike put in.

Output

If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print "YES" (without quotes) in the only line.

Otherwise print "NO" (without quotes) in the first line.

Examples

Input

3
586


Output

NO


Input

2
09


Output

NO


Input

9
123456789


Output

YES


Input

3
911


Output

YES

Note

You can find the picture clarifying the first sample case in the statement above.
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P689A {

  class Vector implements Comparable<Vector> {
    int x, y;

    public Vector(Button b1, Button b2) {
      x = b2.x - b1.x;
      y = b2.y - b1.y;
    }

    @Override
    public int compareTo(Vector v) {
      return ((x != v.x) ? (x - v.x) : (y - v.y));
    }

    @Override
    public String toString() {
      return ("(" + x + ", " + y + ")");
    }
  }

  //----------------------------------------------------------------

  class Button {
    int d, x, y;
    Map<Vector, Button> vb = new TreeMap();

    public Button(int d, int x, int y) {
      this.d = d;
      this.x = x;
      this.y = y;
    }

    public Vector vectorTo(Button b) {
      return new Vector(this, b);
    }

    public void addButton(Button b) {
      vb.put(vectorTo(b), b);
    }

    public Button getButton(Vector v) {
      return vb.get(v);
    }

    @Override
    public String toString() {
      return ("[d=" + d + ", x=" + x + ", y=" + y + "]");
    }
  }

  //----------------------------------------------------------------

  public void run() throws Exception {
    Button [] b = new Button [10];
    b[0] = new Button(0, 1, 3);
    for (int i = 0; i < 9; i++) {
      b[i + 1] = new Button(i + 1, i % 3, i / 3);
    }

    for (int i = 0; i <= 9; i++) {
      for (int j = 0; j <= 9; j++) {
        b[i].addButton(b[j]);
      }
    }

    int n = nextInt();
    Vector [] w = new Vector [n - 1];
    String s = next();
    for (int i = 0; i < (n - 1); i++) {
      w[i] = b[s.charAt(i) - '0'].vectorTo(b[s.charAt(i + 1) - '0']);
    }

    int kw = 0;
but:for (Button sb : b) {
      for (Vector cw : w) {
        if ((sb = sb.getButton(cw)) == null) {
          continue but;
        }
      }

      if ((++kw) > 1) {
        break;
      }
    }

    println((kw == 1) ? "YES" : "NO");
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P689A().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    return ((b > 0) ? gcd(b, a % b) : a);
  }
}