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 PYTHON):

Solution:
from sys import stdin, stdout
from collections import defaultdict
def f(mid, b):
    c = t = 0
    for x in b:
        if x[0] >= mid:
            t += x[1]
        else:
            c += x[0] * x[1]
    return t + c / mid
def main():
    n = int(stdin.readline())
    a = stdin.readline().split()
    d = defaultdict(int)
    for x in a:
        d[x] += 1
    dk = defaultdict(list)
    for k, v in d.items():
        dk[v].append(k)
    b = [(k, len(v)) for k, v in dk.viewitems()]
    b.sort(reverse=True)
    br = bc = be = 1
    for i in xrange(1, n + 1):
        if i * i > n:
            break
        t = f(i, b)
        if i <= t and be < i * t:
            br, bc = i, t
            be = i * t
        if i > t:
            break
    print be
    print br, bc
    ans = [[None] * bc for _ in xrange(br)]
    r = []
    for i in xrange(bc):
        x = i
        for j in xrange(br):
            r.append((j, x))
            x += 1
            if x >= bc:
                x = 0
    r.reverse()
    for k, v in b:
        if k >= br:
            for w in dk[k]:
                for j in xrange(br):
                    if not r:
                        break
                    x, y = r.pop()
                    ans[x][y] = w
        else:
            for w in dk[k]:
                for j in xrange(k):
                    if not r:
                        break
                    x, y = r.pop()
                    ans[x][y] = w
    stdout.write('\n'.join(' '.join(l) for l in ans))
main()