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 read(T &u) {
  u = 0;
  char c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    u = (u << 3) + (u << 1) + (c ^ 48), c = getchar();
  if (flag) u = -u;
}
template <class T>
void write(T u) {
  if (u < 0) printf("-"), u = -u;
  if (u < 10)
    putchar(48 + u);
  else
    write(u / 10), putchar(48 + u % 10);
}
template <class T, class... Arg>
void read(T &u, Arg &...v) {
  read(u);
  read(v...);
}
template <class T>
void write(T u, char c) {
  write(u);
  putchar(c);
}
template <class T>
bool checkmin(T &a, T b) {
  return (b < a ? a = b, 1 : 0);
}
template <class T>
bool checkmax(T &a, T b) {
  return (b > a ? a = b, 1 : 0);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T _max(T a, T b) {
  return (a > b ? a : b);
}
const int N = 400005;
int n, a[N], rec[N];
int top = 0;
pair<int, int> b[N];
vector<vector<int> > mat;
int row, col, total = 0;
pair<int, int> pos[N];
void init() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1]) {
      b[top].first++;
    } else {
      ++top;
      b[top].first = 1;
      b[top].second = a[i];
    }
  }
  sort(b + 1, b + top + 1);
  reverse(b + 1, b + top + 1);
  for (int i = 1; i <= top; ++i) {
    ++rec[b[i].first];
  }
  int rest = top, sum = 0;
  for (int i = 1; i * i <= n; ++i) {
    sum += rec[i] * i;
    rest -= rec[i];
    if (sum + rest * i >= i * i && checkmax(total, (sum + rest * i) / i * i)) {
      row = i;
      col = total / row;
    }
  }
  mat.resize(row + 1);
  for (int i = 0; i < row; ++i) {
    mat[i].resize(col + 1);
  }
  int x = 0, y = 0;
  mat[x][y] = -1;
  pos[1] = make_pair(0, 0);
  for (int rnd = 2; rnd <= total; ++rnd) {
    x = (x + 1) % row;
    y = (y + 1) % col;
    if (mat[x][y] == -1) {
      x = (x + 1) % row;
    }
    pos[rnd] = make_pair(x, y);
    mat[x][y] = -1;
  }
}
void solve() {
  int tmp = 0;
  for (int i = 1; i <= top; ++i) {
    for (int p = 1; p <= _min(row, b[i].first); ++p) {
      ++tmp;
      mat[pos[tmp].first][pos[tmp].second] = b[i].second;
    }
  }
  printf("%d\n%d %d\n", total, row, col);
  for (int i = 0; i < row; ++i) {
    for (int j = 0; j < col; ++j) {
      write(mat[i][j], " \n"[j == col - 1]);
    }
  }
}
int main() {
  int T = 1;
  while (T--) {
    init();
    solve();
  }
  return 0;
}