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.IOException;
import java.io.InputStreamReader;
import java.util.stream.IntStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class  Dragons{
	 
    static class Pair {
        int a;
        int b;
        public Pair(int a, int b){
            this.a=a;
            this.b=b;
        }
    }
	static ArrayList<Pair>[]adjList;
	static boolean[] color;
	static int max=0;
	static ArrayList<ArrayList<Pair>> nodes;
	
	static ArrayList<Long> arr;
    public static HashSet<Long> visited = new HashSet<>();
    public static long n;
    public static long m;
    public static boolean vis[][];
    public static int[] dist = new int[(int) 1e4+1];
	public static void main(String[] args) throws IOException {
     Scanner sc=new Scanner(System.in);
     ArrayList<Integer> al = new ArrayList<Integer>(
             Arrays.asList(1,4,7));
     ArrayList<Integer> bl = new ArrayList<Integer>(
             Arrays.asList(2,5,8,0));
     ArrayList<Integer> cl = new ArrayList<Integer>(
             Arrays.asList(3,6,9));
     int max=Integer.MIN_VALUE;
     int min=Integer.MAX_VALUE;
     sc.nextLine();
   String p=sc.nextLine();
   if((p.contains("9") && p.contains("1")) || (p.contains("0") && p.contains("2")) || (p.contains("0") && p.contains("3")) || (p.contains("0") && p.contains("1")) ) {
	 System.out.println("YES");  
   }else {
	   for(int i=0;i<p.length();i++) {
		   int j=Character.getNumericValue(p.charAt(i));
		   if(al.contains(j)) {
			   max=Math.max(max,1);
			   min=Math.min(min,1);
		   }else if(bl.contains(j)) {
			   max=Math.max(max,2);
			   min=Math.min(min,2);
		   }else {
			   max=Math.max(max,3);
			   min=Math.min(min,3);
		   }
		   
			 
		   
	   }
	   if(max-min<=1) {
		   System.out.println("NO");
	   }else {
		   boolean flag=false;
		   boolean flagp=false;
		   
			   for(int i=0;i<p.length();i++) {
				   int j=Character.getNumericValue(p.charAt(i));
				   if(j==0) {
					   continue;
				   }
				   if(j-3>0 && j-3<=9) {
					   continue;
				   }else {
					   flagp=true;
					   break;
				   }
		   
			   }
			   if(!p.contains("0")) {
		   for(int i=0;i<p.length();i++) {
			   int j=Character.getNumericValue(p.charAt(i));
			   if(j==8) {
				   continue;
			   }
			   if(j+3>0 && j+3<=9) {
				   continue;
			   }else {
				   flag=true;
				   break;
			   }
	   
		   }
		   
		   if(!flag || !flagp) {
			   System.out.println("NO");
		   }else {
			   System.out.println("YES");
		   }
			   }else {
				   if(flagp) {
					   System.out.println("YES");
				   }else {
					   System.out.println("NO");
				   }
			   }
		}
   }
 
   
	}
	static long binomialCoeff(long n, long l) {
        long res = 1;
        
        if (l > n - l) l = n - l;
        
        for (var i = 0; i < l; ++i) {
            res *= 1L*(n - i);
            res /= 1L*(i + 1);
        }
        
        return res;
    }
	static long nCr(long n, long r)
	{
	    return fact(n) / (fact(r) *
	                  fact(n - r));
	}
	static long fact(long n)
	{
	    long res = 1;
	    for (int i = 2; i <= n; i++)
	        res = res * i;
	    return res;
	}
	 

	static int bfs(long m,long n) {
		visited.add(m);
		if(m==n) {
			return 0;
		}
		Queue<Long> q=new LinkedList<Long>();
		q.add(m);
		while(!q.isEmpty()) {
			long curr=q.poll();
			if(curr==n) {
				return dist[(int) curr];
			}
			if(!visited.contains(2*curr) && curr*2<=1e4) {
				q.add(2*curr);
				visited.add(2*curr);
				dist[(int) (2*curr)]=dist[(int) curr]+1;
			}
			if(!visited.contains(curr-1) && curr-1>=1) {
				q.add(curr-1);
				visited.add(curr-1);
				dist[(int) (curr-1)]=dist[(int) curr]+1;
			}
			
			
		}
		
		
		return 0;
	}
	static boolean dividetwothree(long n) {
		while(n!=1) {
			if(n%2==0) {
				n=n/2;
			}else if(n%3==0){
				n=n/3;
			}else {
				return false;
			}
			
			
		}
		return true;
	}
	static boolean isLuckyNumber(int n){
		while(n>0) {
			int y=n%10;
			n=n/10;
			if(y!=4 && y!=7) {
				return false;
			}
		}
		return true;
	}
	static boolean isInteger(double N)
	{
	 
	    // Convert float value
	    // of N to integer
	    long X = (long)N;
	    double temp2 = N - X;
	 
	    // If N is not equivalent
	    // to any integer
	    if (temp2 > 0)
	    {
	        return false;
	    }
	    return true;
	}
	static long isrecursive(long p) {
		if(p==0) {
			return 0;
		}else if(p%2==0) {
			return isrecursive(p/2);
		}else {
			return isrecursive(p/2)+1;
		}
		
	}
	static int islucky(int r) {
		String temp = Integer.toString(r);
		int[] newGuess = new int[temp.length()];
		int tu=0;
		for (int i = 0; i < temp.length(); i++)
		{
		    newGuess[i] = temp.charAt(i) - '0';
		    if(newGuess[i]==4 || newGuess[i]==7) {
		    	tu=tu*10+newGuess[i];
		    }
		}
		return tu;
	}
	static int distance(long l,long m) {
		return (int) (Math.pow(l,2)+Math.pow(m,2));
	}
	static int findSmallest(int N)
	{
	  
	    // Base case
	    if (N == 0)
	        return 2;
	    if (N == 1)
	        return 1;
	  
	    int prime = N, counter = 0;
	    boolean found = false;
	  
	    // Loop continuously until isPrime returns
	    // true for a number greater than n
	    while (!found) {
	        if (isPrime(prime))
	            found = true;
	        else {
	  
	            // If the number is not a prime, then
	            // increment the number by 1 and the
	            // counter which stores the number
	            // to be added
	            prime++;
	            counter++;
	        }
	    }
	  
	    return counter;
	}
	static boolean isPrime(int n)
	{
	    // Base cases
	    if (n <= 1)
	        return false;
	    if (n <= 3)
	        return true;
	  
	    // This is checked so that we can skip
	    // middle five numbers in below loop
	    if (n % 2 == 0 || n % 3 == 0)
	        return false;
	  
	    // For all the remaining numbers, check if
	    // any number is a factor if the number
	    // or not
	    for (int i = 5; i * i <= n; i = i + 6)
	        if (n % i == 0 || n % (i + 2) == 0)
	            return false;
	  
	    // If none of the above numbers are the
	    // factors for the number, then the
	    // given number is prime
	    return true;
	}
	
	
		static int mod(int a, int m)
		{
		    return (a%m + m) % m;
		}
		
	static long getSum(long y)
    {
       long sum = 0;
 
        while (y != 0) {
            sum = sum + y % 10;
            y = y / 10;
        }
 
        return sum;
    }
	static boolean detect(int arr[],int x) {
		long sum=0;
		for(int i=0;i<arr.length;i++) {
			sum+=arr[i];
			if(sum==x) {
				return true;
			}
			
		}
		return false;
	}
	
    static class Node {
        String s;
        int val;
 
        public Node(String a, int v) {
            val = v;
            s = a;
        }
    }
	  
	 public static HashMap<String, Integer> sortByValue(HashMap<String, Integer> hm)
	    {
	        // Create a list from elements of HashMap
	        List<Map.Entry<String, Integer> > list =
	               new LinkedList<Map.Entry<String, Integer> >(hm.entrySet());
	 
	        // Sort the list
	        Collections.sort(list, new Comparator<Map.Entry<String, Integer> >() {
	            public int compare(Map.Entry<String, Integer> o1,
	                               Map.Entry<String, Integer> o2)
	            {
	                return -(o1.getValue()).compareTo(o2.getValue());
	            }
	        });
	         
	        // put data from sorted list to hashmap
	        HashMap<String, Integer> temp = new LinkedHashMap<String, Integer>();
	        for (Map.Entry<String, Integer> aa : list) {
	            temp.put(aa.getKey(), aa.getValue());
	        }
	        return temp;
	    }
	
	 static long lcm(long a, long b)
	    {
	        return (a / gcd(a, b)) * b;
	    }
static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	
	
//static void reduceFraction(int x, int y) 
//{ 
//    int d; 
//    d = gcd(x, y); 
//  
//    x = x / d; 
//    y = y / d; 
//  if(x>0 && y<0) {
//	  x=-x;
//	  y=-y;
//  }
//    System.out.println(y); 
//} 
	
	static long gcd(long a, long b) {
		return a%b == 0 ? b : gcd(b,a%b);
	}
	 static int getSum(int n)
	    {
	        int sum = 0;
	 
	        while (n != 0) {
	            sum = sum + n % 10;
	            n = n / 10;
	        }
	 
	        return sum;
	    }
	
	static boolean[] sieve(int n) {
		
		
		boolean isPrime[] = new boolean[n+1];
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) continue;
			for(int j = 2*i; j <= n; j+=i) {
				isPrime[j] = true;
			}
		
		} 
		return isPrime;
		
	}
}