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 double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<vector<int>> ans;
void check() {
  for (int i = (0); i < ((int)((ans).size())); ++i) {
    vector<int> tut = ans[i];
    sort(tut.begin(), tut.end());
    tut.resize(unique(tut.begin(), tut.end()) - tut.begin());
    assert((int)((tut).size()) == (int)((ans[i]).size()));
  }
  for (int i = (0); i < ((int)((ans[0]).size())); ++i) {
    vector<int> tut((int)((ans).size()));
    for (int j = (0); j < ((int)((ans).size())); ++j) tut[j] = ans[j][i];
    sort(tut.begin(), tut.end());
    tut.resize(unique(tut.begin(), tut.end()) - tut.begin());
    assert((int)((tut).size()) == (int)((ans).size()));
  }
}
void solve(int n, int m, set<pair<int, int>>& S) {
  ans.assign(n, vector<int>(m, 0));
  vector<pair<int, int>> vec;
  for (auto i : S) vec.push_back({i.second, i.first});
  int x = 0, y = 0;
  int ryad = 0;
  for (auto tut : vec) {
    int chyslo = tut.first, cnt = tut.second;
    while (cnt--) {
      ans[x][y] = chyslo;
      x++;
      y++;
      if (x < n && y < m) continue;
      if (x == n) {
        if (n < m) {
          ryad--;
          if (ryad < 0) ryad += m;
        } else
          ryad++;
        x = 0;
        y = ryad;
        continue;
      }
      y -= m;
    }
  }
  check();
  cout << n * m << endl;
  cout << n << ' ' << m << endl;
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) cout << ans[i][j] << ' ';
    cout << endl;
  }
  exit(0);
}
const int N = 400000 + 7;
vector<int> dil[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n = 400000;
  cin >> n;
  for (int i = (1); i < (n + 1); ++i)
    for (int j = i; j <= n; j += i) dil[j].push_back(i);
  map<int, int> mp;
  for (int i = (0); i < (n); ++i) {
    int x = 1;
    cin >> x;
    mp[x]++;
  }
  set<pair<int, int>> S;
  for (auto i : mp) S.insert({i.second, i.first});
  int cnt_diff = (int)((S).size());
  int most = S.rbegin()->first;
  for (int SQ = (n + 1) - 1; SQ >= (1); --SQ) {
    for (auto sm : dil[SQ]) {
      int bg = SQ / sm;
      if (sm > bg) break;
      if (cnt_diff < bg) continue;
      if (most > sm) continue;
      solve(sm, bg, S);
    }
    auto it = S.end();
    --it;
    auto tut = *it;
    S.erase(it);
    tut.first--;
    assert(tut.first > 0);
    S.insert(tut);
    most = S.rbegin()->first;
  }
  assert(false);
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}