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:
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class B
   {
      public static void main(String hi[]) throws Exception
      {
         int[] map = new int[20]; int lmao = 0;
         for(int i=2; i < 59; i++)
            if(isPrime(i))
               map[lmao++] = i;
         int[] masks = new int[60];
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         short[] arr = new short[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Short.parseShort(st.nextToken());
         short[][] dp = new short[N][1<<16];
         for(int i=0; i < N; i++)
            Arrays.fill(dp[i], (short)3000);
         dp[0][0] = (short)(arr[0]-1);
         Node[][] par = new Node[N][1<<16];
         par[0][0] = new Node(-69, (short)1);
         for(short v=2; v < 59; v++)
         {
            int mask = 0;
            for(int b=0; b < 16; b++)
               if(v%map[b] == 0)
                  mask |= 1<<b;
            if(dp[0][mask] > Math.abs(arr[0]-v))
            {
               dp[0][mask] = (short)Math.abs(arr[0]-v);
               par[0][mask] = new Node(-69, v);
            }
            masks[v] = mask;
         }
         for(short i=1; i < N; i++)
         {
            for(int mask=0; mask < (1<<16); mask++)
            {
               dp[i][mask] = (short)(dp[i-1][mask]+arr[i]-1);
               par[i][mask] = new Node(mask, (short)1);
            }
            for(short v=2; v < 59; v++)
            {
               int startmask = (~masks[v])&((1<<16)-1);
               for(int mask=startmask; ; mask=(mask-1)&startmask)
               {
                  if(par[i][mask|masks[v]] == null || dp[i][mask|masks[v]] > dp[i-1][mask]+Math.abs(arr[i]-v))
                  {
                     if(par[i-1][mask] != null)
                     {
                        dp[i][mask|masks[v]] = (short)(dp[i-1][mask]+Math.abs(arr[i]-v));
                        par[i][mask|masks[v]] = new Node(mask, v);
                     }
                  }
                  if(mask == 0)
                     break;
               }
            }
         }
         short[] res = new short[N];
         int currmask = 0;
         for(int mask=1; mask < (1<<16); mask++)
            if(dp[N-1][mask] < dp[N-1][currmask] && par[N-1][mask] != null)
               currmask = mask;
         //System.out.println(currmask);
         short currdex = (short)(N-1);
         while(currdex >= 0)
         {
            Node parent = par[currdex][currmask];
            res[currdex] = parent.val;
            currdex--;
            currmask = parent.mask;
         }
         for(int i=0; i < N; i++)
            System.out.print(res[i]+" ");
      }
      public static boolean isPrime(long n) 
      {
          if(n < 2) return false;
          if(n == 2 || n == 3) return true;
          if(n%2 == 0 || n%3 == 0) return false;
          long sqrtN = (long)Math.sqrt(n)+1;
          for(long i = 6L; i <= sqrtN; i += 6) {
              if(n%(i-1) == 0 || n%(i+1) == 0) return false;
          }
          return true;
      }
   }
   class Node
   {
      public int mask;
      public short val;
      
      public Node(int b, short c)
      {
         mask = b;
         val = c;
      }
   }