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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
const double pi = acos(-1);
const int mod = 1e9 + 7;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int T;
int n;
int a[N];
int b[N];
int c[N];
int cnt;
int d[N];
int e[N];
int f[N];
int ne[N];
vector<int> vec[N];
void solve() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = a[i];
  sort(a + 1, a + 1 + n);
  cnt = unique(a + 1, a + 1 + n) - a - 1;
  for (int i = 1; i <= cnt; i++) {
    c[i] = d[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int pw = lower_bound(a + 1, a + 1 + cnt, b[i]) - a;
    c[pw]++;
    ne[pw] = a[pw];
  }
  for (int i = 1; i <= cnt; i++) {
    vec[c[i]].push_back(i);
    d[c[i]]++;
  }
  e[n] = d[n];
  for (int i = n - 1; i >= 1; i--) e[i] = d[i] + e[i + 1];
  int bsta = 0, bstb = 0, bst = 0;
  int tmp = 0;
  for (int i = 1; i <= n; i++) {
    tmp += e[i];
    int pq = tmp / i;
    if (pq && pq * i > bst && i <= pq) {
      bsta = i;
      bstb = pq;
      bst = pq * i;
    }
  }
  cout << bst << "\n";
  cout << bsta << " " << bstb << "\n";
  for (int i = 0; i < n; i++) f[i] = 0;
  int xx = 0, yy = 0;
  int ck = 0;
  for (int k = n; k >= 1; k--) {
    for (auto i : vec[k]) {
      for (int j = 1, pf = min(c[i], bsta); j <= pf && ck < bst; j++) {
        int pl = xx * bstb + yy;
        while (f[pl]) {
          xx = (xx + 1) % bsta;
          pl = xx * bstb + yy;
        }
        f[pl] = ne[i];
        ck++;
        xx = (xx + 1) % bsta;
        yy = (yy + 1) % bstb;
      }
    }
  }
  for (int i = 0; i < bsta; i++) {
    for (int j = 0; j < bstb; j++) {
      cout << f[i * bstb + j] << " ";
    }
    cout << "\n";
  }
}
int main() {
  T = 1;
  for (int i = 1; i <= T; i++) solve();
}