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.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {

    static int MAX = 1000001;

    public void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        String s = in.next();

        for (int i = 0; i < n; i++) {
            a[i] = s.charAt(i) - '0';
            if (a[i] == 0) a[i] = 11;
        }
        int[] x = new int[n - 1];
        int[] y = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            int cx1 = (a[i] - 1) / 3;
            int cy1 = (a[i] - 1) % 3;

            int cx2 = (a[i + 1] - 1) / 3;
            int cy2 = (a[i + 1] - 1) % 3;
            x[i] = cx2 - cx1;
            y[i] = cy2 - cy1;
        }
        int r = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                if (i == 3 && j != 1) {
                    continue;
                }
                int cx1 = i;
                int cy1 = j;
                boolean b=true;
                for (int l = 0; l < n - 1; l++) {
                    cx1 += x[l];
                    cy1 += y[l];
                    if (cx1 == 3 && cy1 == 1) {
                        continue;
                    }
                    if (cx1 < 0 || cx1 > 2 || cy1 < 0 || cy1 > 2) {
                        b= false;
                    }
                }
                if (b) {
                    r++;
                }
            }
        }
        if (r > 1) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

}


class Utils {

    public static int binarySearch(int[] a, int key) {
        int s = 0;
        int f = a.length;
        while (f > s) {
            int mid = (s + f) / 2;
            if (a[mid] > key) {
                f = mid - 1;
            } else if (a[mid] <= key) {
                s = mid + 1;
            }
        }
        return -1;
    }
}

class Pair<T, U> {
    public T a;
    public U b;

    public Pair(T a, U b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public boolean equals(Object obj) {
        Pair<T, U> p = (Pair<T, U>) obj;
        return p.a.equals(a) || p.a.equals(b);
    }

    @Override
    public int hashCode() {
        return 42;
    }
}


class Vect {
    public int a;
    public int b;

    public Vect(int a, int b) {
        this.a = a;
        this.b = b;
    }
}

class Triple<T, U, P> {
    public T a;
    public U b;
    public P c;

    public Triple(T a, U b, P c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
}


class Scanner {
    BufferedReader in;
    StringTokenizer tok;

    public Scanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    private String tryReadNextLine() {
        try {
            return in.readLine();
        } catch (Exception e) {
            throw new InputMismatchException();
        }
    }

    public String nextToken() {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(next());
        }
        return tok.nextToken();
    }

    public String next() {
        String newLine = tryReadNextLine();
        if (newLine == null)
            throw new InputMismatchException();
        return newLine;
    }

    public int nextInt() {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }
}