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>
namespace {
using namespace std;
template <typename T>
inline bool whitespace(const vector<T> &) {
  return false;
}
template <typename T>
inline bool whitespace(const T &) {
  return true;
}
inline bool whitespace(const char) { return false; }
template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
  os << p.first << (whitespace(p.second) ? " " : "") << p.second << '\n';
  return os;
}
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &t : v) {
    os << t << (whitespace(t) ? " " : "");
  }
  os << "\n";
  return os;
}
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
template <typename C>
void incr_sort(C &v) {
  stable_sort(v.begin(), v.end());
}
template <typename C>
void decr_sort(C &v) {
  stable_sort(v.rbegin(), v.rend());
}
template <typename T>
T sum(const vector<T> &v) {
  T s = 0;
  for (T value : v) s += value;
  return s;
}
template <typename T>
vector<T> prefix_sum(const vector<T> &v) {
  vector<T> res(v.size());
  res[0] = v[0];
  for (int i = 1; i < v.size(); ++i) res[i] = res[i - 1] + v[i];
  return res;
}
class ExitException : exception {};
template <typename T>
void answer(T ans, ostream &os = cout) {
  os << ans << "\n";
  throw ExitException();
}
void answer(ostream &os = cout) {
  os << "\n";
  throw ExitException();
}
istream &is = cin;
struct autoint {
  int x;
  autoint() { is >> x; }
  operator int() { return x; }
};
template <typename T>
struct autoread : T {
  template <typename... Args>
  autoread(Args &&...args) : T(args...) {
    is >> *dynamic_cast<T *>(this);
  }
};
}  // namespace
void solve();
signed main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  int t = 1;
  do {
    try {
      solve();
    } catch (ExitException) {
    }
  } while (--t);
  return 0;
}
pair<int, int> pos(int i, int p, int q) {
  if (p == q) return {i % p, (i % p + (i / p) + q) % q};
  return {i % p, (i % p - (i / p) + q) % q};
}
void answer(int p, int q, map<int, int> &count) {
  vector<pair<int, int>> pairs;
  for (auto p : count) pairs.push_back(p);
  stable_sort(pairs.begin(), pairs.end(),
              [](const pair<int, int> &p1, const pair<int, int> &p2) {
                return p1.second > p2.second;
              });
  vector<vector<int>> ans(p, vector<int>(q));
  auto it = pairs.begin();
  for (int i = 0; i < p * q; ++i) {
    if (!it->second) ++it;
    if (it->second > p) it->second = p;
    pair<int, int> point = pos(i, p, q);
    ans[point.first][point.second] = it->first;
    --it->second;
  }
  answer(ans);
}
int countsums(vector<int> &sorted_counts, vector<int> &prefixsum, int max) {
  auto i = lower_bound(sorted_counts.begin(), sorted_counts.end(), max);
  if (i == sorted_counts.begin()) return max * sorted_counts.size();
  return prefixsum[i - sorted_counts.begin() - 1] +
         max * (sorted_counts.size() - (i - sorted_counts.begin()));
}
void solve() {
  autoint n;
  map<int, int> count;
  for (int i = 0; i < n; ++i) count[autoint()]++;
  vector<int> counts;
  for (auto pair : count) counts.push_back(pair.second);
  vector<int> sums(sqrt(n.x) + 2, 0);
  incr_sort(counts);
  auto prefixsum = prefix_sum(counts);
  for (int i = 0; i < sums.size(); ++i)
    sums[i] = countsums(counts, prefixsum, i);
  int S = 0;
  pair<int, int> params;
  for (int p = 1; p * p <= n; ++p) {
    int q = sums[p] / p;
    if (p > q) break;
    if (S < p * q) {
      S = p * q;
      params = {p, q};
    }
  }
  cout << S << "\n" << params;
  answer(params.first, params.second, count);
}