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;
int add(int a, int b) {
  long long x = a + b;
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
  return x;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long pw(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed() {
  long long a = rng();
  return a;
}
int n, v[400002];
pair<int, int> bst[400002];
void ciur() {
  for (int i = 1; i <= 400000; ++i) {
    for (int j = i; j <= 400000; j += i) {
      if (bst[j].first == 0)
        bst[j] = {i, j / i};
      else if (abs(bst[j].second - bst[j].first) > abs(i - j / i))
        bst[j] = {i, j / i};
    }
  }
}
map<int, int> mp;
vector<pair<int, int> > ordrem;
void tri(int n) {
  if (bst[n].first > bst[n].second) swap(bst[n].first, bst[n].second);
  if (ordrem.back().first <= bst[n].first) {
    cout << n << '\n';
    cout << bst[n].first << " " << bst[n].second << '\n';
    vector<int> mat[bst[n].first + 2];
    for (int i = 0; i <= bst[n].first; ++i) mat[i].resize(bst[n].second + 5);
    vector<int> nr;
    for (int i = ordrem.size() - 1; i >= 0; --i) {
      if (mp.find(ordrem[i].second) != mp.end()) {
        for (int j = 0; j < ordrem[i].first; ++j)
          nr.push_back(ordrem[i].second);
        mp.erase(ordrem[i].second);
      }
    }
    int stc = 0;
    for (int i = 0; i < n; i += bst[n].first) {
      for (int j = i; j < i + bst[n].first; ++j)
        mat[j - i][(stc + j - i) % bst[n].second] = nr[j];
      ++stc;
    }
    for (int i = 0; i < bst[n].first; cout << '\n', ++i)
      for (int j = 0; j < bst[n].second; ++j) cout << mat[i][j] << " ";
    exit(0);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    ++mp[v[i]];
    ordrem.push_back({mp[v[i]], v[i]});
  }
  sort(ordrem.begin(), ordrem.end());
  ciur();
  for (int i = n; i >= 1; --i) {
    tri(i);
    ordrem.pop_back();
  }
  return 0;
}