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.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
//import java.util.logging.Level;
//import java.util.logging.Logger;
public class Main

{
     BufferedReader read;
     BufferedWriter write;
    public static void main(String args[]) throws Exception
    {
        
      new Main().init("1");
    }
   int p[]=new int[20],pl=0,set[]=new int[60];
   int a[],n,dp[][],next[][];
   boolean done[][];;
     void init(String name) throws Exception
    {
         for(int i=2;i<59;i++)if(isPrime(i))p[pl++]=i;
         for(int i=2;i<60;i++)for(int j=0;j<pl&&p[j]<=i;j++)if(i%p[j]==0)set[i]|=1<<j;
        // System.out.println(pl+" p= "+Arrays.toString(p));
        read=ri();//rf(name+".txt");
         n=i(read.readLine());
        // n=100;pl=18;
        a=ia(read.readLine());
        dp=new int[n][1<<pl];
        next=new int[n][1<<pl];
        done=new boolean[n][1<<pl];
        long t1=new Date().getTime();
        dp(0,0);
        int ans[]=new int[n],st=0,mask=(1<<10)-1;
        for(int i=0;i<n;i++)
        {
          ans[i]=next[i][st]&mask;
          st=next[i][st]>>10;
          
        }
        StringBuilder sb=new StringBuilder();
       for(int i=0;i<n-1;i++)sb.append(ans[i]).append(" ");
        sb.append(ans[n-1]);
       
        System.out.println(sb);
        // System.out.println(new Date().getTime()-t1);
   }
  
     int dp(int i,int st)
    {
      if(i>=n)return 0;
      if(done[i][st])return dp[i][st];
      done[i][st]=true;
      if(st+1==1<<pl)
      {
          next[i][st]=(st<<10)|1;
          return dp[i][st]=a[i] - 1 + dp(i + 1, st);
      }
      int ans=a[i]-1+dp(i+1,st);
      next[i][st]=(st<<10)|1;
      for(int j=2;j-a[i]<(a[i]-1);j++)if((set[j]&st)==0)
      {
          int temp=abs(j-a[i])+dp(i+1,st|set[j]);
          if(temp>=ans)continue;
          ans=temp;
          next[i][st]=((st|set[j])<<10)|j;
      }
     
      return dp[i][st]=ans;
     }
     boolean st(int num,int i)
    {
         return (num>>i&1)!=0;
     }
    
    boolean isPrime(int num)
    {
        if(num<4)return true;
        for(int i=2;i<num;i++)if(num%i==0)return false;
        return true;
    }



int i(String s){return Integer.parseInt(s.trim());}
long l(String s){return Long.parseLong(s.trim());}
 int[] ia(String s1){String s[]=s1.trim().split(" ");int p[]=new int[s.length];for(int i=0;i<s.length;i++)p[i]=Integer.parseInt(s[i]);return p;}
 long[] la(String s)
 {
     String s1[]=s.split(" ");
     long la[]=new long[s1.length];
     for(int i=0;i<s1.length;i++)la[i]=l(s1[i]);
     return la;
 }
static BufferedWriter wf(String s) throws Exception{return new BufferedWriter(new FileWriter(new File(s)));}
static BufferedReader rf(String s) throws Exception{return new BufferedReader(new FileReader(new File(s)));}
static BufferedReader ri() throws Exception{return new BufferedReader(new InputStreamReader(System.in));}
}