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;
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
template <typename Tp>
void read(Tp &x) {
  x = 0;
  long long fh = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') {
      fh = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= fh;
}
long long n, m;
long long a[4000005], ta[4000005], tat, cnt[4000005];
struct node {
  long long num, tim;
  bool operator<(node b) const { return tim < b.tim; }
};
priority_queue<node> q;
long long pn, ans[4000005], tot, sum, rst;
long long get_ps(long long x, long long y) { return (y - 1) * pn + x; }
signed main() {
  long long ffl = 0;
  read(n);
  rst = n;
  for (long long i = 1; i <= n; i++) read(a[i]), ta[++tat] = a[i];
  sort(ta + 1, ta + tat + 1);
  tat = unique(ta + 1, ta + tat + 1) - ta - 1;
  for (long long i = 1; i <= n; i++)
    a[i] = lower_bound(ta + 1, ta + tat + 1, a[i]) - ta, cnt[a[i]]++;
  for (long long i = 1; i <= tat; i++) q.push((node){i, cnt[i]});
  while (!q.empty()) {
    node x = q.top();
    q.pop();
    if (x.tim * x.tim > n) {
      x.tim--, q.push(x);
      rst--;
      ffl = 1;
      continue;
    }
    if (!pn) {
      if (rst - x.tim < x.tim * (x.tim - 1)) {
        x.tim--, q.push(x);
        rst--;
        continue;
      }
      long long tmp = q.top().tim;
      if (ffl && (rst - 1) % tmp < rst % x.tim) {
        x.tim--, q.push(x);
        rst--;
        continue;
      }
      pn = x.tim;
    }
    for (long long i = 1; i <= x.tim; i++) ans[++tot] = x.num, sum++;
  }
  long long ppn = pn, mi = sum % pn;
  for (long long i = pn; i * pn <= sum; i++) {
    if (sum % i < mi) {
      mi = sum % i;
      ppn = i;
    }
  }
  pn = ppn;
  m = sum / pn;
  if (pn > m) swap(pn, m);
  printf("%lld\n", pn * m);
  printf("%lld %lld\n", pn, m);
  for (long long i = 1; i <= pn; i++) {
    for (long long j = 2 - i, tt = 1; tt <= m; tt++, j++) {
      if (j < 1) j += m;
      if (j == m + 1) j = 1;
      printf("%lld ", ta[ans[get_ps(i, j)]]);
    }
    puts("");
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}