Problem: You are given n integers. You need to choose a subset and put the chosen numbers in a beautiful rectangle (rectangular matrix). Each chosen number should occupy one of its rectangle cells, each cell must be filled with exactly one chosen number. Some of the n numbers may not be chosen.

A rectangle (rectangular matrix) is called beautiful if in each row and in each column all values are different.

What is the largest (by the total number of cells) beautiful rectangle you can construct? Print the rectangle itself.

Input

The first line contains n (1 ≤ n ≤ 4⋅10^5). The second line contains n integers (1 ≤ a_i ≤ 10^9).

Output

In the first line print x (1 ≤ x ≤ n) — the total number of cells of the required maximum beautiful rectangle. In the second line print p and q (p ⋅ q=x): its sizes. In the next p lines print the required rectangle itself. If there are several answers, print any.

Examples

Input


12
3 1 4 1 5 9 2 6 5 3 5 8


Output


12
3 4
1 2 3 5
3 1 5 4
5 6 8 9


Input


5
1 1 1 1 1


Output


1
1 1
1

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
 
public class A {
	public static void main (String[] args) { new A(); }
 
	A() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");
 
		int n = fs.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextInt();
		sort(a);
		int dt = 0;
		for(int i = 0; i < n; i++) {
			if(i+1 < n && a[i] == a[i+1]) continue;
			dt++;
		}
		Num[] nums = new Num[dt];
		dt = 0;
		for(int i = 0; i < n; i++) {
			int j = i;
			while(j < n && a[i] == a[j]) j++;
			nums[dt++] = new Num(a[i], j-i);
			i = --j;
		}
		Arrays.sort(nums);
		
		int[] pref = new int[nums.length];
		for(int i = 0; i < nums.length; i++) {
			pref[i] = nums[i].freq;
			if(i > 0) pref[i] += pref[i-1];
		}
		
		int bestWid = 0, bestHei = 0;
		for(int wid = 1; wid <= n; wid++) {
			int lo = 0, hi = nums.length-1, pos = -1;
			for(int bs = 0; bs < 50 && lo <= hi; bs++) {
				int mid = (lo+hi)/2;
				if(nums[mid].freq >= wid) {
					pos = mid;
					hi = mid-1;
				}
				else {
					lo = mid+1;
				}
			}
			int sum = 0;
			if(pos != -1) {
				sum += wid*(nums.length-pos);
				if(pos > 0) sum += pref[pos-1];
			}
			else {
				sum += pref[nums.length-1];
			}
			
			int hei = sum/wid;
			if(wid <= hei && wid*hei > bestWid*bestHei) {
				bestWid = wid;
				bestHei = hei;
			}
		}
		
		int area = bestHei*bestWid;
		out.println(area);
		out.println(bestHei + " " + bestWid);
		int[][] res = new int[bestHei][bestWid];
		boolean[][] vis = new boolean[bestHei][bestWid];
		
		int row = 0, col = 0, put = 0;
		all: for(int i = nums.length-1; i >= 0; i--) {
			int lim = Math.min(nums[i].freq, bestWid);
			for(int k = 0; k < lim; k++) {
				if(vis[row][col]) {
					col++;
				}
				vis[row][col] = true;
				res[row][col] = nums[i].val;
				put++;
				if(put == area) break all;
				row++; col++;
				if(row >= bestHei) row = 0;
				if(col >= bestWid) col = 0;
			}
		}
		for(int i = 0; i < bestHei; i++) {
			for(int j = 0; j < bestWid; j++) {
				out.print(res[i][j] + " ");
			}
			out.println();
		}
		out.close();
	}
	
	void sort(int[] a) {
		Random rand = new Random();
		int n = a.length;
		for(int i = 0; i < n; i++) {
			int x = rand.nextInt(n), y = rand.nextInt(n);
			int t = a[x]; a[x] = a[y]; a[y] = t;
		}
		Arrays.sort(a);
	}
	
	class Num implements Comparable<Num> {
		int val, freq;
		Num(int a, int b) {
			val = a; freq = b;
		}
		public int compareTo(Num n) {
			return Integer.compare(freq, n.freq);
		}
	}
	
	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
		}
		String next() {
			if(st.hasMoreTokens()) return st.nextToken();
			try { st = new StringTokenizer(br.readLine()); } catch (Exception e) {}
			return next();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
}