#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
long long cnt[400100];
map<long long, long long> M;
long long RM[400100];
long long a[400100];
long long freq[400100];
long long qtd[400100];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    M[a[i]];
  }
  long long k = 0;
  for (map<long long, long long>::iterator it = M.begin(); it != M.end();
       it++) {
    it->second = ++k;
    RM[k] = it->first;
  }
  for (long long i = 1; i <= n; i++) {
    a[i] = M[a[i]];
    cnt[a[i]]++;
  }
  long long mxcnt = 0;
  for (long long i = 1; i <= k; i++) {
    qtd[cnt[i]] += cnt[i];
    mxcnt = max(mxcnt, cnt[i]);
    freq[cnt[i]]++;
  }
  for (long long i = n; i >= 1; i--) {
    freq[i] += freq[i + 1];
  }
  for (long long i = 1; i <= n; i++) {
    qtd[i] += qtd[i - 1];
  }
  long long mx = 0;
  long long best = 1;
  long long p = 1, q = 1;
  for (long long i = n; i >= 1; i--) {
    long long cp = i;
    long long cq = qtd[i] / i;
    if (cp <= cq) {
      if (cp * cq > mx) {
        mx = cp * cq;
        p = cp;
        q = cq;
      }
    }
    qtd[i - 1] += (i - 1) * freq[i];
  }
  best = p;
  vector<long long> v2, v3, to;
  for (long long i = 1; i <= k; i++) {
    if (cnt[i] >= p) {
      for (long long j = 0; j < p; j++) v2.push_back(i);
    } else {
      for (long long j = 0; j < min(p, cnt[i]); j++) v3.push_back(i);
    }
  }
  for (long long i = 0; i < v3.size(); i++) {
    v2.push_back(v3[i]);
  }
  to = v2;
  long long mat[p + 1][q + 1];
  long long vis[p + 1][q + 1];
  for (long long i = 0; i < p; i++) {
    for (long long j = 0; j < q; j++) {
      vis[i][j] = false;
      mat[i][j] = 0;
    }
  }
  long long cp = 0, cq = 0;
  for (long long i = 0; i < p * q; i++) {
    if (i >= to.size()) {
      cout << "PUTZ"
           << "\n";
      return 0;
    }
    if (vis[cp][cq]) {
      cp = (cp + 1) % p;
    }
    mat[cp][cq] = to[i];
    vis[cp][cq] = true;
    cp++;
    cq++;
    cp %= p;
    cq %= q;
  }
  cout << p * q << "\n";
  cout << p << " " << q << "\n";
  for (long long i = 0; i < p; i++) {
    for (long long j = 0; j < q; j++) {
      cout << RM[mat[i][j]] << " ";
    }
    cout << "\n";
  }
}

### Prompt

Please create a solution in cpp to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
long long cnt[400100];
map<long long, long long> M;
long long RM[400100];
long long a[400100];
long long freq[400100];
long long qtd[400100];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    M[a[i]];
  }
  long long k = 0;
  for (map<long long, long long>::iterator it = M.begin(); it != M.end();
       it++) {
    it->second = ++k;
    RM[k] = it->first;
  }
  for (long long i = 1; i <= n; i++) {
    a[i] = M[a[i]];
    cnt[a[i]]++;
  }
  long long mxcnt = 0;
  for (long long i = 1; i <= k; i++) {
    qtd[cnt[i]] += cnt[i];
    mxcnt = max(mxcnt, cnt[i]);
    freq[cnt[i]]++;
  }
  for (long long i = n; i >= 1; i--) {
    freq[i] += freq[i + 1];
  }
  for (long long i = 1; i <= n; i++) {
    qtd[i] += qtd[i - 1];
  }
  long long mx = 0;
  long long best = 1;
  long long p = 1, q = 1;
  for (long long i = n; i >= 1; i--) {
    long long cp = i;
    long long cq = qtd[i] / i;
    if (cp <= cq) {
      if (cp * cq > mx) {
        mx = cp * cq;
        p = cp;
        q = cq;
      }
    }
    qtd[i - 1] += (i - 1) * freq[i];
  }
  best = p;
  vector<long long> v2, v3, to;
  for (long long i = 1; i <= k; i++) {
    if (cnt[i] >= p) {
      for (long long j = 0; j < p; j++) v2.push_back(i);
    } else {
      for (long long j = 0; j < min(p, cnt[i]); j++) v3.push_back(i);
    }
  }
  for (long long i = 0; i < v3.size(); i++) {
    v2.push_back(v3[i]);
  }
  to = v2;
  long long mat[p + 1][q + 1];
  long long vis[p + 1][q + 1];
  for (long long i = 0; i < p; i++) {
    for (long long j = 0; j < q; j++) {
      vis[i][j] = false;
      mat[i][j] = 0;
    }
  }
  long long cp = 0, cq = 0;
  for (long long i = 0; i < p * q; i++) {
    if (i >= to.size()) {
      cout << "PUTZ"
           << "\n";
      return 0;
    }
    if (vis[cp][cq]) {
      cp = (cp + 1) % p;
    }
    mat[cp][cq] = to[i];
    vis[cp][cq] = true;
    cp++;
    cq++;
    cp %= p;
    cq %= q;
  }
  cout << p * q << "\n";
  cout << p << " " << q << "\n";
  for (long long i = 0; i < p; i++) {
    for (long long j = 0; j < q; j++) {
      cout << RM[mat[i][j]] << " ";
    }
    cout << "\n";
  }
}

```