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>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N;
int A[400011];
int B[400011];
int sums[400011];
void MAIN() {
  scanf("%d", &N);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d", A + i);
  sort(A, A + N);
  vector<pair<int, int> > P;
  for (int i = 0; i < N;) {
    int j = i;
    while (j < N && A[i] == A[j]) j++;
    P.emplace_back(j - i, A[i]);
    i = j;
  }
  sort(P.begin(), P.end());
  for (int i = 0, i_len = (P.size()); i < i_len; ++i)
    sums[i + 1] = sums[i] + P[i].first;
  int ans = 0;
  for (int h = 1, idx = 0;; h++) {
    while (idx < (int)P.size() && P[idx].first <= h) idx++;
    int has = sums[idx] + ((int)P.size() - idx) * h;
    int w = has / h;
    if (h <= w && ans < h * w) {
      ans = h * w;
    }
    if (w < h) break;
  }
  for (int h = 1, idx = 0;; h++) {
    while (idx < (int)P.size() && P[idx].first <= h) idx++;
    int has = sums[idx] + ((int)P.size() - idx) * h;
    int w = has / h;
    if (h * w == ans) {
      int cnt = 0;
      vector<pair<int, int> > P2;
      for (int i = 0, i_len = (P.size()); i < i_len; ++i) {
        int g = min(h, min(ans - cnt, P[i].first));
        if (g) {
          P2.emplace_back(g, P[i].second);
          cnt += g;
        }
      }
      sort(P2.begin(), P2.end());
      reverse(P2.begin(), P2.end());
      vector<int> v;
      for (__typeof((P2).begin()) e = (P2).begin(), e_end = (P2).end();
           e != e_end; ++e)
        for (int i = 0, i_len = (e->first); i < i_len; ++i)
          v.push_back(e->second);
      printf("%d\n%d %d\n", ans, h, w);
      cnt = 0;
      for (int j = 0, j_len = (w); j < j_len; ++j) {
        int a = 0, b = j;
        for (int k = 0, k_len = (h); k < k_len; ++k) {
          B[a * w + b] = v[cnt++];
          a++;
          b++;
          if (a == h) a = 0;
          if (b == w) b = 0;
        }
      }
      for (int i = 0, i_len = (h); i < i_len; ++i)
        for (int j = 0, j_len = (w); j < j_len; ++j) {
          printf("%d%c", B[i * w + j], " \n"[j == w - 1]);
        }
      return;
    }
  }
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}