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.io.*;
import java.math.*;
@SuppressWarnings("unchecked")
public class Main {
    InputReader ir = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    final long mod = 993960000099397l;
    int nmask = 0;
    HashMap <Integer, Integer> map = new HashMap();
    int n;
    int arr[];
    int mem[][] = new int[101][1 << 16 + 1];
    int mem1[][] = new int[101][1 << 16 + 1];
    int ans[];
    int f[];
    void solve() {
        int id = 0;
        f = new int[68];
        for(int i = 2; i <= 53; i++) {
            boolean fl = true;
            
            f[i] = nmask;
            for(int j = 2;j * j <= i; j++) {
                if(i % j == 0) {
                    fl = false;
                    break;
                }
            }
            if(fl) {
                map.put(i, id++);
            }
        }
        for(int i = 2; i <= 53; i++) {
            check(0, i);
            f[i] = nmask;
        }
        for(int i = 0; i < 101; i++)
            Arrays.fill(mem[i], -1);
        n = ir.readInt();
        ans = new int[n];
        arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = ir.readInt();
        }
      
       rec(0,0);
       int max = 100000000;
        id = -1;
        int mask = 0;
       for(int i = 0; i < n; i++) {
           out.print(mem1[i][mask]+" ");
           mask |= f[mem1[i][mask]];
       }
         out.println();
        
    }
    
    int rec(int idx, int mask) {

        if(idx == n) {
            return 0;
        }
        if(mem[idx][mask] != -1)
            return mem[idx][mask];
        int min = (arr[idx] - 1) + rec(idx + 1, mask);
        mem1[idx][mask] = 1;
        for(int i = 2; i <= 53; i++) {
            if((f[i]&mask) == 0) {
                int prev = min;
                min = Math.min(min, Math.abs(arr[idx] - i) + rec(idx + 1, mask|f[i]));
                if(min < prev) {
                    mem1[idx][mask] = i;
                }
            }
        }
        return mem[idx][mask] = min;
    }

    boolean check(int mask, int num) {
        int nm = 0;
        List <Integer> l = new ArrayList();
        for(int key : map.keySet()) {
            if(num % key == 0)
                l.add(key);
        }
        
        for(int i : l) {
            nm |= (1 << map.get(i));
        }
        nmask = nm;
        if((nm & mask) == 0)
            return true;
        return false;
    }
    void run() {
        solve();
        out.close();
    }

    public static void main(String args[]){
        new Main().run();
    }
}

class InputReader {
 
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;
 
    public InputReader(InputStream stream) {
        this.stream = stream;
    }
 
    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
    public final int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
    }
    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }
        public double readDouble() {
        return Double.parseDouble(readString());
    }
 
    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public String next() {
        return readString();
    }
 
    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}