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.Arrays;
import java.util.StringTokenizer;
import java.util.Vector;

public class Main {

	public static void main(String[] args) throws IOException {
		TaskD solver = new TaskD();
		solver.read();
		solver.solve();
	}

}

class InputReader {
	private BufferedReader input;
	private StringTokenizer tokenizer;
	
	public InputReader ( InputStream stream ) {
		input = new BufferedReader ( new InputStreamReader ( stream ), 32768 );
		tokenizer = null;
	}
	
	public void close() throws IOException {
		try {
			input.close();
		}
		catch ( IOException error ) {
			throw new RuntimeException ( error );
		}
	}
	
	public String next () {
		while ( tokenizer == null || !tokenizer.hasMoreTokens() ) {
			try {
				tokenizer = new StringTokenizer ( input.readLine() );
			}
			catch ( IOException error ) {
				throw new RuntimeException ( error );
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt( next() );
	}
	
	public double nextDouble() {
		return Double.parseDouble ( next() );
	}
	
	public long nextLongLong() {
		return Long.parseLong( next() );
	}
	
	public String nextString() {
		return next();
	}
	
	public boolean nextBool() {
		return Boolean.parseBoolean( next() );
	}
	
}

class TaskD {
	private InputReader in;
	private PrintWriter out;
	
	private int INF = 100100;
	private int n, countPrimes, maxNumber;
	private int[] a, numbers;
	private int[][] dp, next;
	
	public TaskD() {
		in = new InputReader ( System.in );
		out = new PrintWriter ( System.out );
	}
	
	public void read() throws IOException {
		n = in.nextInt();
		
		a = new int[n + 1];
		
		maxNumber = 0;
		for ( int i = 1; i <= n; ++ i ) {
			a[i] = in.nextInt();
			maxNumber = Math.max ( maxNumber, a[i] );
		}
		
		maxNumber *= 2;
		findPrimes();
		
		in.close();
		
	}
	
	private void findPrimes () {
		boolean[] vis = new boolean[maxNumber + 1];
		numbers = new int[maxNumber + 1];
		
		countPrimes = 0;
		for ( int i = 2; i <= maxNumber; ++ i ) {
			if ( vis[i] == false ) {
				for ( int j = i; j <= maxNumber; j += i ) {
					numbers[j] |= ( 1 << countPrimes );
					if ( i != j ) vis[j] = true;
				}
				countPrimes ++;
			}
		}
		
		dp = new int[n + 1][ ( 1 << countPrimes ) ];
		next = new int[n + 1][ ( 1 << countPrimes ) ];
	}
	
	public void solve() {
		int i, j, k;
		
		for ( i = 1; i <= n; ++ i ) {
			Arrays.fill( dp[i], INF );
		}
		
		for ( i = 1; i <= n; ++ i ) {
			for ( j = 1; j < maxNumber; ++ j ) {
				int x = ( ~numbers[j] ) & ( ( 1 << countPrimes ) - 1 );
				for ( k = x; ; k = ( k - 1 ) & x ) {
					int newMask = k | numbers[j];
					if ( dp[i][newMask] > dp[i - 1][k] + Math.abs ( a[i] - j ) ) {
						dp[i][newMask] = dp[i - 1][k] + Math.abs ( a[i] - j );
						next[i][newMask] = j;
					}
					
					if ( k == 0 ) break;
				}
			}
		}
		
		int mn = INF + 1, idx = 0;
		for ( i = 0; i < ( 1 << countPrimes ); ++ i ) {
			if ( dp[n][i] < mn ) {
				mn = dp[n][i];
				idx = i;
			}
		}
		
		Vector < Integer > answer = new Vector < Integer >();
		for ( i = n; i >= 1; -- i ) {
			answer.add ( next[i][idx] );
			idx &= ~numbers[next[i][idx]];
		}
		
		for ( i = ( int ) answer.size() - 1; i >= 0; -- i ) {
			out.print ( answer.elementAt(i) + " " );
		}
		
		out.println();
		out.close();
	}
	
}