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 long long INF = 1e9 + 7;
void fast() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
}
void build_mas(int a, int b, vector<vector<int>>& vall, int n) {
  cout << a * b << endl;
  cout << a << ' ' << b << endl;
  int x = 0, y = 0;
  vector<vector<int>> ans(a, vector<int>(b, 0));
  for (int i = n; i >= 1; --i) {
    for (auto& el : vall[i]) {
      for (int j = 0; j < min(i, a); j++) {
        if (ans[x][y] != 0) {
          x++;
          x %= a;
        }
        if (ans[x][y] == 0) {
          ans[x][y] = el;
        }
        x = (x + 1) % a;
        y = (y + 1) % b;
      }
    }
  }
  for (auto& el : ans) {
    for (auto& val : el) {
      cout << val << ' ';
    }
    cout << endl;
  }
}
signed main() {
  fast();
  int n;
  cin >> n;
  vector<int> m1(n);
  map<int, int> kol;
  vector<vector<int>> vall(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> m1[i];
    if (kol.count(m1[i])) {
      kol[m1[i]]++;
    } else {
      kol[m1[i]] = 1;
    }
  }
  for (auto& el : kol) {
    vall[el.second].push_back(el.first);
  }
  int pref = 0;
  vector<int> cur(n + 1, 0);
  vector<int> pref1(n + 1, 0);
  for (auto& el : kol) {
    for (int i = 1; i <= el.second; i++) {
      cur[i] += i;
    }
    if (el.second + 1 > n) {
      break;
    }
    pref1[el.second + 1] += el.second;
  }
  for (int i = 1; i <= n; i++) {
    pref1[i] += pref1[i - 1];
  }
  for (int i = 0; i <= n; i++) {
    cur[i] += pref1[i];
  }
  for (int a = 1; a <= n; a++) {
    int val = cur[a];
    int b = val / a;
    if (a * b > pref && a <= b) {
      pref = a * b;
    }
  }
  for (int a = 1; a <= n; a++) {
    int val = cur[a];
    int b = val / a;
    if (a * b == pref && a <= b) {
      build_mas(a, b, vall, n);
      return 0;
    }
  }
  return 0;
}