Problem: Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.

<image>

A sequence of positive integers bi is harmony if and only if for every two elements of the sequence their greatest common divisor equals 1. According to an ancient book, the key of the chest is a harmony sequence bi which minimizes the following expression:

<image>

You are given sequence ai, help Princess Twilight to find the key.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of elements of the sequences a and b. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 30).

Output

Output the key — sequence bi that minimizes the sum described above. If there are multiple optimal sequences, you can output any of them.

Examples

Input

5
1 1 1 1 1


Output

1 1 1 1 1 

Input

5
1 6 4 2 8


Output

1 5 3 1 8 

Solution (in JAVA):

Solution:
import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	//  PriorityQueue<P> que = new PriorityQueue<P>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
	//static int mod = 1000000009,r=0; ArrayList<Integer> l[]= new ArrayList[n];
   // static int dx[]={1,-1,0,0};
//	static int dy[]={0,0,1,-1};
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
//  static int dy[]={0,0,1,-1,1,-1,1,-1};
	//static Set<Integer> set = new HashSet<Integer>();p
	
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //  
	Reader sc = new Reader(System.in);


 //,a=sc.nextInt(),b=sc.nextInt();
 	 int n=sc.nextInt(),x[]=new int[n];
     int p[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53},l=p.length;
	 int f[]=new int[59];
     
	for (int i = 0; i <n ; i++){
		x[i]=sc.nextInt();
	}
	
	   for(int t=2;t<59;t++){ int d=t;
	     for (int i = 0; i < p.length; i++) {
			int c=0;
			while(d%p[i]==0){  d/=p[i]; c++;}
			if(0<c){ f[t]|=1<<i; }
			if(d==1)break;
		 }		
	   }
	   
	   
	 //    for(int t=1;t<59;t++)db(t,Integer.toBinaryString(f[t]));  
	    int d[][][]=new int[3][n+1][1<<l],r=1<<28;

	    for (int i = 1; i <=n ; i++)fill(d[0][i],1<<28);
	    
	for (int i = 0; i <n ; i++){
       for(int t=1;t<59;t++){
		  
    	   int k=f[t]^((1<<l)-1);
    	   
    	   for(int j=k; 0<=j ;j=(j-1)&k){
    		   
    		   //d[0][i+1][j|f[t]]=min(d[0][i+1][j|f[t]],d[0][i][j]+abs( t-x[i] ));
    		   if( d[0][i+1][j|f[t]]>d[0][i][j]+abs( t-x[i] ) ){
    			   d[0][i+1][j|f[t]]=d[0][i][j]+abs( t-x[i] );   
    			   d[1][i+1][j|f[t]]=j;
    			   d[2][i+1][j|f[t]]=t;
    		   }
    		   
    		   if(j==0)break;
    		   
    	   }	   
       }
	}
	
	int a=0;
	for (int i = 0; i <1<<l ; i++){ if(r>d[0][n][i]){ r=d[0][n][i];  a=i; } }
	
	//db(r,a, d[1][n][a] );
	
	int k[]=new int[n];
	k[n-1]=a;
	for (int i = n-2; 0<=i ; i--){
	//	db(d[1][i+2][k[i+1]]);     
		k[i]= d[1][i+2][k[i+1]]  ;
	}
	
	for (int i = 0; i <n ; i++){
		System.out.print(d[2][i+1][k[i]]+" ");
	}
	
	//System.out.println(r);

}


static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}


  /* 
   * class P implements Comparable<P>{
//		implements Comparable<Pair>
		int id; long d;
		P(int id,long d){
			this.id=id;
			this.d=d;
		} 
		public int compareTo(P x){
		   	 return  0<=d-x.d?1:-1 ;  //ascend
		   }
	 
 }



class Pair implements Comparable<Pair>{
//	implements Comparable<Pair>
	int a,b;
	Pair(int a,int b){
		this.a=a;
		this.b=b;
	} 
	public int compareTo(Pair x){
	   	 return a-x.a; //descend
	   }
}*/

class Reader
{ 
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}