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;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
inline void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  return 0;
}
int n;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
inline void solve() {
  read(n);
  unordered_map<long long, int, custom_hash> f;
  for (int i = 0; i < n; ++i) {
    int x;
    read(x);
    ++f[x];
  }
  vector<int> atF(n + 1, 0);
  for (auto i : f) {
    for (int j = 1; j <= i.second; ++j) {
      ++atF[j];
    }
  }
  int ai = 0, aj = 0, have = 0;
  for (int i = 1; i * i <= n; ++i) {
    have += atF[i];
    if (have < i * i) continue;
    int bi = i, bj = have / i;
    if (bi * bj > ai * aj) ai = bi, aj = bj;
  }
  vector<int> vals;
  for (auto i : f) {
    int tak = min(ai, i.second);
    for (int j = 0; j < tak; ++j) {
      vals.push_back(i.first);
    }
  }
  sort(vals.begin(), vals.end(), [&](int i1, int i2) {
    if (f[i1] == f[i2]) return i1 < i2;
    return f[i1] > f[i2];
  });
  vals.resize(ai * aj);
  vector<vector<int> > ans(ai, vector<int>(aj));
  prn(ai * aj);
  prn(ai, aj);
  int ctr = 0;
  for (int j = 0; j < aj; ++j) {
    int cj = j;
    for (int i = 0; i < ai; ++i) {
      ans[i][cj % aj] = vals[ctr++];
      ++cj;
    }
  }
  for (int i = 0; i < ai; ++i) {
    for (int j = 0; j < aj; ++j) {
      prs(ans[i][j]);
    }
    prn("");
  }
}