In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l_{i}.

Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that maximizes their total area. Each stick is used in making at most one rectangle, it is possible that some of sticks remain unused. Bending sticks is not allowed.

Sticks with lengths a_1, a_2, a_3 and a_4 can make a rectangle if the following properties are observed:  a_1 ≤ a_2 ≤ a_3 ≤ a_4  a_1 = a_2  a_3 = a_4 

A rectangle can be made of sticks with lengths of, for example, 3 3 3 3 or 2 2 4 4. A rectangle cannot be made of, for example, sticks 5 5 5 7.

Ilya also has an instrument which can reduce the length of the sticks. The sticks are made of a special material, so the length of each stick can be reduced by at most one. For example, a stick with length 5 can either stay at this length or be transformed into a stick of length 4.

You have to answer the question — what maximum total area of the rectangles can Ilya get with a file if makes rectangles from the available sticks?


-----Input-----

The first line of the input contains a positive integer n (1 ≤ n ≤ 10^5) — the number of the available sticks.

The second line of the input contains n positive integers l_{i} (2 ≤ l_{i} ≤ 10^6) — the lengths of the sticks.


-----Output-----

The first line of the output must contain a single non-negative integer — the maximum total area of the rectangles that Ilya can make from the available sticks.


-----Examples-----
Input
4
2 4 4 2

Output
8

Input
4
2 2 3 5

Output
0

Input
4
100003 100004 100005 100006

Output
10000800015

Difficulty: interview

Starter code:

Solutions:
arr = [0] * (10 ** 6 + 1)
n = int(input())
for i in input().split():
    arr[int(i)] += 1
i = 10 ** 6
j = i
k = i
c = 0
while j > 0:
    if arr[j] % 2 == 1 and (arr[j] > 1 or c == 0):
        arr[j - 1] += 1
        c = 1
    else:
        c = 0
    j -= 1
r = 0
while i > 0 and k > 0:
    if arr[i] < 2:
        if i == k:
            k -= 1
        i -= 1
    elif i == k and arr[i] < 4:
        k -= 1
    elif arr[k] < 2:
        k -= 1
    else:
        r += i * k
        arr[i] -= 2
        arr[k] -= 2
print(r)

n = int(input())
l = list(map(int, input().split()))
l.sort(key=lambda x: -x)
i = 0
cur = 0
ans = 0
while i < len(l)-1:
    if l[i] == l[i+1] or l[i]-1 == l[i+1]:
        if cur == 0:
            cur = l[i+1]
        else:
            ans += cur*l[i+1]
            cur = 0
        i += 2
    else:
        i += 1
print(ans)


def __starting_point():
    input()
    data = sorted(map(int, input().split()), key=lambda x: -x)

    if len(data) < 4:
        print(0)
        return

    total = 0
    i = 0

    while i < len(data) - 3:
        if abs(data[i] - data[i + 1]) > 1:
            i += 1
            continue

        success = False
        for j in range(i + 2, len(data) - 1):
            if abs(data[j] - data[j + 1]) > 1:
                continue

            success = True
            total += min(data[i], data[i + 1]) * min(data[j], data[j + 1])
            i = j + 2
            break

        if not success:
            i += 1

    print(total)


__starting_point()

n = int(input())
s = map(int, input().split())
s = list(reversed(sorted(s)))
i = 1
k =[]
while i < n:
    if s[i-1] - s[i] == 1:
        k.append(s[i])
        i += 1
    elif s[i-1] == s[i]:
        k.append(s[i])
        i += 1
    i +=1
ans = 0
for i in range(1, len(k), 2):
    ans += k[i]*k[i-1]
print(ans)

n = int(input())
l = [int(x) for x in input().split()]

l.sort()

l2 = [0] * n
prev = l[0]
count = 1
k = 0

for i in range(1, n):
    if l[i] != prev:
        l2[k] = [prev, count]
        k += 1
        prev = l[i]
        count = 1
    else:
        count += 1

l2[k] = [prev, count]
k += 1
for i in range(k-1, 0, -1):
    if l2[i][1] % 2 == 1 and l2[i-1][0] == (l2[i][0] - 1):
        l2[i-1][1] += 1
    l2[i][1] //= 2
l2[0][1] //= 2
i = k-1
j = k-1
res = 0
while i >= 0 and j >= 0:
    if i == j:
        res += l2[i][0] * l2[i][0] * (l2[i][1] // 2)
        l2[i][1] %= 2
        if l2[i][1] == 0:
            i -= 1
            j -= 1
        else:
            i -= 1

    else:
        if l2[i][1] == 0:
            i -= 1
            continue
        res += l2[i][0] * l2[j][0]
        l2[i][1] -= 1
        j = i

print(res)


n = int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
a = []
i = 0
while i < len(l) - 1:
    #print(l[i], l[i + 1])
    if l[i] == l[i + 1]:
        a.append(l[i])
        i += 2
    else:
        if l[i] == l[i + 1] + 1:
            a.append((l[i] - 1))
            i += 2
        else:
            i += 1

#print(a)
if len(a) % 2 != 0:
    a.append(0)

s, i = 0, 0
while i < len(a):
    s += a[i] * a[i + 1]
    i += 2
print(s)






















n=int(input())
L=[int(x) for x in input().split()]
L.sort(reverse=True)
i=0
while i<n-1:
	if L[i]-1==L[i+1]:
		L[i]-=1
		i+=1
	elif L[i]==L[i+1]:
		i+=1
	i+=1
val=[]
i=0
while i<n-1:
	if L[i]==L[i+1]:
		val.append(L[i])
		i+=1
	i+=1
area=0
n=len(val)
i=0
while i<n-1:
	area+=val[i]*val[i+1]
	i+=2
print(area)


ans = 0
n = 0
n = int(input(""))
l = input("")
st = []
for x in l.split(" "):
    st.append(int(x))
st.sort()
i = n-1
while i>=3:
    if st[i]>st[i-1]+1:
        i = i -1
        continue
    l = st[i-1]
    i = i -2
    while i>0 and st[i]>st[i-1]+1:
        i=i-1
    if i == 0:
        break
    b = st [i-1]
    ans = ans + l*b
    i = i - 2
print(ans)


n = int(input())
l = []
inline = input().split()
for i in range (n):
    l.append(int(inline[i]))
l.sort()
right_equal = 1
ans = 0
if len(l) >= 4:
    for i in range(len(l) - 2, -1, -1):
        if l[i] != l[i + 1]:
            if right_equal % 2 != 0:
                if l[i + 1] - l[i] == 1:
                    l[i + 1] -= 1
                    right_equal = 2
                else:
                    l.pop(i + 1)
            else:
                right_equal = 1
        else:
            right_equal += 1
if len(l) >= 4:
    if l[0] != l[1]:
        l.pop(0)
    flag = 1
    for i in range(len(l) - 2, -1, -2):
        if flag == 1:
            c = l[i]
        else:
            ans += c * l[i]
            c = 0
        flag = 1 - flag
print (ans)

n = int(input())

lst = []
lst.extend(list(map(int, input().split())))

tarea = 0

lst.sort()
lst = lst[::-1]
lst.append(0)

i = 0
mark = 0
ar = []
while i != n:
    if (lst[i] - lst[i+1])<=1:
        ar.append(lst[i+1])
        mark += 1
        i += 2
    else:
        i += 1
    if mark == 2:
        tarea = tarea + ar[0]*ar[1]
        ar = []
        mark = 0

print(tarea)
        
    


sux = 0
two = 0
x=int(input())
s=list(map(int, input().split(' ')))

t = [0] * (1000001)
for i in s:
    t[i] += 1
for i in range(len(t)-1, 0, -1):
    if t[i]%2==1 and t[i-1]>0:
        t[i] -= 1
        t[i-1] += 1
    elif t[i]%2==1 and t[i]>0:
        t[i] -= 1
for i in range(len(t)-1, 0, -1):
    if two != 0 and t[i] != 0:
        sux += i*two
        two = 0
        t[i] -= 2
    if t[i] % 4 == 0:
        sux += (t[i]//4)*i*i
    else:
        sux += (t[i]//4)*i*i
        if two != 0:
            sux += i*two
            two = 0
            
        else:
            two = i
            
    
print(sux)


n = int(input())
l = list(map(int, input().split()))
m = {}
m2 = set()
for i in range(1, 10**6 + 1):
    m[i] = 0
for i in range(n):
    m[l[i]] += 1
    m2.add(l[i])
    if l[i] >= 2:
        m2.add(l[i] - 1)
m1 = []

for i in range(10**6, 1, -1):
    if m[i] % 2 == 1 and m[i - 1] > 0:
        m[i] -= 1
        m[i - 1] += 1
    elif m[i] % 2 == 1:
        m[i] -= 1
for i in m2:
    if m[i] != 0:
        m1.append(i)
m1.sort(reverse = True)

cnt = 0
for i in range(len(m1)):
    cnt += (m[m1[i]]//4)*(m1[i]**2)
    if m[m1[i]] % 4 == 2 and i != len(m1) - 1:
        m[m1[i + 1]] -= 2
        cnt += m1[i + 1]*m1[i]
print(cnt)
        
        
    
        


n = int(input())
l = list(map(int, input().split()))
m = {}
m2 = set()
for i in range(1, 10**6 + 1):
    m[i] = 0
for i in range(n):
    m[l[i]] += 1
    m2.add(l[i])
    if l[i] >= 2:
        m2.add(l[i] - 1)
m1 = []

for i in range(10**6, 1, -1):
    if m[i] % 2 == 1 and m[i - 1] > 0:
        m[i] -= 1
        m[i - 1] += 1
    elif m[i] % 2 == 1:
        m[i] -= 1
for i in m2:
    if m[i] != 0:
        m1.append(i)
m1.sort(reverse = True)

cnt = 0
for i in range(len(m1)):
    cnt += (m[m1[i]]//4)*(m1[i]**2)
    if m[m1[i]] % 4 == 2 and i != len(m1) - 1:
        m[m1[i + 1]] -= 2
        cnt += m1[i + 1]*m1[i]
print(cnt)
        
        
    
        


#!/c/Python34/python
# coding: utf-8 ans


def main():
    n = int(input())
    L = sorted(map(int, input().split()))
    L.reverse()
    K = []
    i = 1
    while(i < n):
        if L[i-1] == L[i]:
            K.append(L[i])
            i += 1
        elif L[i-1]-L[i] == 1:
            K.append(L[i])
            i += 1
        i += 1
    ans = 0
    for i in range(1, len(K), 2):
        ans += K[i-1] * K[i]
    print(ans)
    #print(K)

def __starting_point():
    main()

__starting_point()

_ = int(input())
as_ = list(sorted(map(int, input().split())))

def get_pair():
    while len(as_) >= 2:
        s0 = as_.pop()
        s1 = as_.pop()
        if s0-1 == s1 or s0 == s1:
            return s1
        as_.append(s1)
    return None

ans = 0
tb = get_pair()
lr = get_pair()
while not (tb is None or lr is None):
    ans += tb * lr
    tb = get_pair()
    lr = get_pair()
print(ans)


def main():
    n = int(input())
    l = [int(i) for i in input().split()]
    l.sort()
    l.reverse()
    candidate = []
    i = 1
    while (i < n):
        if (l[i - 1] - l[i] <= 1):
            candidate.append(min(l[i - 1], l[i]))
            i += 2
        else:
            i += 1

    area = 0
    for i in range(1, len(candidate), 2):
        area += candidate[i] * candidate[i - 1]
    return area


def __starting_point():
    print(main())
__starting_point()

n = int(input())
ls = list(map(int, input().split()))
ls.sort(reverse=True)

area = 0
pairs = []
i = 0
while i < len(ls)-1:
    if (ls[i] - ls[i+1]) > 1:
        i += 1
    else:
        pairs.append(ls[i+1])
        i += 2
    if len(pairs) == 2:
        area += pairs.pop() * pairs.pop()
print(area)


n = int(input())
maxn = 10**6 + 2
cnt = [0] * maxn
for x in map(int, input().split()):
    cnt[x] += 1
ansv = []
for i in range(maxn - 2, 1, -1):
    ansv += [i] * ((cnt[i] + (cnt[i+1] & 1)) >> 1)
    if cnt[i] > 0:
        cnt[i] += cnt[i+1] & 1
ans = 0
for i in range(1, len(ansv), 2):
    ans += ansv[i] * ansv[i-1]
print(ans)

s = input()
lst = [int(i) for i in input().split()]
lst.sort()
lst = lst[::-1]
n = 0
k = 0
while len(lst) >= 2:
    if lst[0] == lst[1] or lst[0] == lst[1]+1:
        if k != 0:
            n += k*lst[1]
            lst.pop(0)
            lst.pop(0)
            k = 0
        else:
            k = lst[1]
            lst.pop(0)
            lst.pop(0)

    else:
        lst.pop(0)
print(n)


n, v, ps, pp = int(input()), 0, 0, 0
for l in sorted(map(int, input().split()), reverse=True):
    if ps == 0 or ps > l + 1:
        ps = l
    elif pp == 0:
        pp, ps = l, 0
    else:
        v, pp, ps = v + pp * l, 0, 0
print(v)

n = int(input())
sticks = list(map(int, input().split()))

length = [0] * 1000000
miv = 1000000
mav = 0
answ = 0
for i in range(len(sticks)):
	length[sticks[i]-1] = length[sticks[i]-1] + 1
	if sticks[i]-1 > mav:
		mav = sticks[i] - 1
	if sticks[i] -1 < miv:
		miv = sticks[i] -1

length = length[miv:mav+1]
for i in range(len(length)-1, -1, -1):
	if length[i] % 2 == 1:
		if i > 0 and length[i-1] > 0:
			length[i] = length[i] - 1
			length[i-1] = length[i-1] + 1
		else:
			length[i] = length[i] - 1

square = []
for i in range(len(length)-1, -1, -1):

	while length[i] > 0:
		square.append(i + miv + 1)
		length[i] = length[i] - 2
		if len(square) == 2:
			answ += square[0] * square[1]
			square = []
print(answ)

I = lambda : map(int,input().split())
n = int(input())
p = list(I())
cnt = [0] * 1000001
for i in p: cnt[i] += 1
for i in range(1000000,1,-1):
    if cnt[i] % 2 == 1 and cnt[i - 1] > 0:
        cnt[i] -= 1
        cnt[i - 1] += 1
    elif cnt[i] % 2 == 1 and cnt[i - 1] == 0:
        cnt[i] -= 1
p = 0
ans = 0
for i in range(1000000,1,-1):
    if cnt[i] != 0:
        if p != 0:
            cnt[i] -= 2
            ans += p * i
            p = 0
        ans += i * i * (cnt[i] // 4)
        if cnt[i] % 4 != 0:
            p = i
print (ans)

from collections import Counter

input()
lengths = [int(i) for i in input().split()]
cnt = Counter(lengths)
lengths.sort(reverse=True)
total_square = 0

for le in lengths:
    if cnt[le] % 2 != 0:
        if cnt[le-1] > 0:
            cnt[le-1] += 1
        cnt[le] -= 1

for le in lengths:
    if cnt[le] >= 4:
        cnt[le] -= 4
        total_square += le ** 2
    elif cnt[le] < 4 and cnt[le] > 0:
        min_le = le - 1
        while min_le > 0 and cnt[min_le] < 2:
            min_le -= 1
        cnt[le] -= 2
        cnt[min_le] -= 2
        total_square += le * min_le

print(total_square)


import sys
def otb(l):
    i = 0
    while i < n - 1:
        if l[i] - 1 == l[i + 1]:
            l[i] -= 1
            i += 1
        elif l[i] == l[i + 1]:
            i += 1
        i += 1
    znach = []
    i = 0
    while i < n - 1:
        if l[i] == l[i + 1]:
            znach.append(l[i])
            i += 1
        i += 1
    return znach
def ploshad(n,znach):
    summa = 0
    n = len(znach)
    for i in range(0, n - 1, 2):
        summa += znach[i] * znach[i + 1]
    sys.stdout.write(str(summa))

n = int(sys.stdin.readline())
l = []
l = [int(j) for j in sys.stdin.readline().split()]
l.sort(reverse=True)
znach=otb(l)
ploshad(n,znach)


n = int(input())
a, b = 0, 0
ans = 0
for i in sorted(map(int,input().split()),reverse=True):
    if a == 0 or a > i + 1:
        a = i
    elif b == 0:
        a, b= 0, i
    else:
        ans += i * b
        a, b = 0, 0
print(ans)