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>
#pragma GCC optimize("-O3")
using namespace std;
long long MOD = 1e9 + 7;
long long mpow(long long a, long long b) {
  if (b >= (MOD - 1)) b %= (MOD - 1);
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2);
  t1 *= t1;
  t1 %= MOD;
  if (b % 2) t1 *= a;
  t1 %= MOD;
  return t1;
}
long long mpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2, p);
  t1 *= t1;
  t1 %= p;
  if (b % 2) t1 *= a;
  t1 %= p;
  return t1;
}
long long modinverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long range(long long l, long long r) { return l + rand() % (r - l + 1); }
long long n;
long long m, r, c;
vector<pair<long long, long long> > vec;
vector<long long> pr;
long long check(long long v) {
  long long l1 = 0, r1 = ((long long)(vec).size());
  while (l1 != r1) {
    long long mid = (l1 + r1) / 2;
    if (vec[mid].first < v)
      l1 = mid + 1;
    else
      r1 = mid;
  }
  long long am = (((long long)(vec).size()) - l1) * v + (l1 ? pr[l1 - 1] : 0);
  return am;
}
void solve() {
  cin >> n;
  map<long long, long long> m1;
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    m1[t]++;
  }
  for (auto it : m1) {
    vec.push_back(make_pair(it.second, it.first));
  }
  sort((vec).begin(), (vec).end());
  long long pre = 0;
  for (long long i = 0; i < ((long long)(vec).size()); i++) {
    pre += vec[i].first;
    pr.push_back(pre);
  }
  for (int i = 1; i < n + 1; i++) {
    long long l = 0, r1 = i;
    while (l != r1) {
      long long mid = (l + r1 + 1) / 2;
      if (check(mid) >= i * mid)
        l = mid;
      else
        r1 = mid - 1;
    }
    if (i * l > m) {
      m = i * l;
      r = i;
      c = l;
    }
  }
  for (long long i = 0; i < ((long long)(vec).size()); i++)
    vec[i] = make_pair(min(c, vec[i].first), vec[i].second);
  cout << m << "\n";
  cout << r << " " << c << "\n";
  long long a[r][c];
  long long cr = 0, cc = 0;
  long long ci = ((long long)(vec).size()) - 1;
  while (1) {
    a[cr][cc] = vec[ci].second;
    vec[ci].first--;
    if (vec[ci].first == 0) ci--;
    if (cc == c - 1) {
      cr = (cr - cc + 1 + r) % r;
      cc = 0;
    } else {
      cr++;
      cc++;
      cr %= r;
    }
    if (cc == 0 && cr == 0) break;
  }
  for (long long i = 0; i < r; i++) {
    for (long long j = 0; j < c; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}