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 <class T>
void dbs(string str, T t) {
  cout << str << " : " << t << "\n";
}
template <class T, class... second>
void dbs(string str, T t, second... s) {
  long long idx = str.find(',');
  cout << str.substr(0, idx) << " : " << t << ", ";
  dbs(str.substr(idx + 1), s...);
}
template <class T>
void prc(T a, T b) {
  cout << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cout << ", ";
    cout << *i;
  }
  cout << "]\n";
}
template <class T>
void prall(T a) {
  prc(a.begin(), a.end());
}
const int inf = 1000 * 1000 * 1000 + 9;
const long long infl = 1ll * inf * inf;
const int mod = 1000 * 1000 * 1000 + 7;
const int nax = 4e5 + 5;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  vector<int> comp_cnt(n + 1, 0);
  vector<pair<int, int> > val;
  int amt = ((int)cnt.size());
  int ctr = 0;
  vector<int> id(n + 1);
  for (auto p : cnt) {
    comp_cnt[ctr] = p.second;
    id[ctr] = p.first;
    val.push_back({p.second, p.first});
    ctr++;
  }
  sort(val.begin(), val.end());
  reverse(val.begin(), val.end());
  int m = ((int)cnt.size());
  int mx = -1, my = -1;
  int max_pos = -1;
  for (int x = 1; x <= m; x++) {
    int y = min(n / x, m);
    if (x <= y) {
      int count = 0;
      for (int i = 0; i < amt; i++) {
        count += min(x, comp_cnt[i]);
      }
      if (count < x * y) {
        int yy = count / x;
        if (yy >= x) {
          y = yy;
        }
      }
      if (count >= x * y) {
        if (max_pos < x * y) {
          mx = x, my = y;
          max_pos = x * y;
        }
      }
    }
  }
  cout << mx * my << '\n';
  vector<vector<int> > mat(mx, vector<int>(my));
  vector<pair<int, int> > order;
  for (int s = 0; s < my; s++) {
    int i = 0, j = s;
    while (i < mx) {
      order.push_back({i, j});
      i++;
      j++;
      if (j >= my) j = 0;
    }
  }
  int place = 0;
  for (int i = 0; i < amt; i++) {
    comp_cnt[i] = min(comp_cnt[i], mx);
    val[i].first = min(val[i].first, mx);
  }
  for (auto p : order) {
    int x = p.first, y = p.second;
    while (val[place].first == 0) {
      place++;
    }
    val[place].first--;
    mat[x][y] = val[place].second;
  }
  cout << mx << " " << my << '\n';
  for (int i = 0; i < mx; i++) {
    for (int j = 0; j < my; j++) {
      cout << mat[i][j] << " ";
    }
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout << fixed << setprecision(4);
  int t = 1, i = 1;
  while (t--) {
    i++;
    solve();
  }
}