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 long long LINF = 1E18;
const int INF = 1E9;
const int MOD = 1E9 + 7;
const int N = 4E5 + 5;
int t = 1;
int n, a[N];
void Input() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void Prepare() {}
int cnt = 0;
pair<int, int> x[N];
int res = 0;
int R, C;
vector<int> Path[N];
bool Cho[N];
bool cmp(pair<int, int> a1, pair<int, int> a2) { return a1.first > a2.first; }
void Solve() {
  sort(a + 1, a + 1 + n);
  x[1] = {1, a[1]};
  cnt = 1;
  for (int i = 2; i <= n; i++)
    if (a[i] == x[cnt].second)
      x[cnt].first++;
    else
      x[++cnt] = {1, a[i]};
  sort(x + 1, x + 1 + cnt, cmp);
  for (int r = 1; r * (r - 20) <= n; r++) {
    int sum = 0;
    for (int i = 1; i <= cnt; i++) sum += min(x[i].first, r);
    int c = sum / r;
    if (c < r) continue;
    if (r * c >= res) {
      res = r * c;
      R = r;
      C = c;
    }
  }
  int r = R, c = C;
  if (r > c) swap(r, c);
  int all = r + c - 1;
  for (int i = 1; i <= r; i++) Path[i].resize(c + 5);
  for (int i = 1; i <= cnt; i++) x[i].first = min(x[i].first, r);
  int Pointer = 1;
  for (int i = r; i <= c; i++) {
    int xx = 1;
    int yy = i - r + 1;
    for (int j = 1; j <= r; j++) {
      Path[xx][yy] = x[Pointer].second;
      x[Pointer].first--;
      if (x[Pointer].first <= 0) Pointer++;
      xx++;
      yy++;
    }
  }
  int dem = r;
  int dem2 = 0;
  for (int i = r - 1; i >= 1; i--) {
    int xx, yy;
    dem--;
    dem2++;
    xx = 1;
    yy = c - dem + 1;
    for (int j = 1; j <= dem; j++) {
      Path[xx][yy] = x[Pointer].second;
      x[Pointer].first--;
      if (x[Pointer].first <= 0) Pointer++;
      xx++;
      yy++;
    }
    xx = r - dem2 + 1;
    yy = 1;
    for (int j = 1; j <= dem2; j++) {
      Path[xx][yy] = x[Pointer].second;
      x[Pointer].first--;
      if (x[Pointer].first <= 0) Pointer++;
      xx++;
      yy++;
    }
  }
  cout << res << endl;
  cout << r << " " << c << endl;
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) cout << Path[i][j] << " ";
    cout << endl;
  }
}
void check() {
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++)
      for (int k = j + 1; k <= C; k++)
        if (Path[i][j] == Path[i][k]) {
          cout << "WRONG ANSWER!";
          return;
        }
  }
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= R; j++)
      for (int k = j + 1; k <= R; k++)
        if (Path[j][i] == Path[k][i]) {
          cout << "WRONG ANSWER!";
          return;
        }
  }
  cout << "ACCEPT!";
}
int main() {
  if (fopen("606F"
            ".inp",
            "r")) {
    freopen(
        "606F"
        ".inp",
        "r", stdin);
    freopen(
        "606F"
        ".out",
        "w", stdout);
  }
  Input();
  Prepare();
  while (t--) Solve();
}