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: MEDIUM_HARD
Tags: Sorting

Mathematics

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

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


n = int(input())
l = list(map(int, input().split()))
l.sort()
side = []
i = n - 1
while i > 0:
	s = l[i]
	if s == l[i - 1]:
		side.append(s)
		i -= 2
	elif s == l[i - 1] + 1:
		side.append(s - 1)
		i -= 2
	else:
		i -= 1
side.sort()
i = len(side) - 1
num = 0
while i > 0:
	num += side[i] * side[i - 1]
	i -= 2
print(num)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = sorted(int_array(), reverse=1)
x = 0
this = []
for i in a:
	if not this:
		this.append(i)
	elif this[-1] == i:
		this.append(i)
	elif len(this) == 2:
		this.append(i)
	elif this[-1] == i + 1:
		this[-1] -= 1
		this.append(i)
	else:
		this.pop()
		this.append(i)
	if len(this) == 4:
		x += this[0] * this[-1]
		this = []
print(x)


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	mx = 10 ** 6 + 2
	lens = [0] * mx
	ans = 0
	for el in arr:
		lens[el] += 1
	for i in range(mx - 1, 0, -1):
		if lens[i] & 1:
			if lens[i - 1] > 0:
				lens[i - 1] += 1
			lens[i] -= 1
	rem = 0
	for i in range(mx - 1, 0, -1):
		cur = lens[i]
		if cur == 0:
			continue
		if rem != 0:
			ans += rem * i
			cur -= 2
			rem = 0
		ans += cur // 4 * i * i
		if cur & 2:
			rem = i
	print(ans)
tt = 1
for test in range(tt):
	solve()


n = int(input())
l = [int(i) for i in input().split()]
l = sorted(l)
rr = []
new = l[::-1]
io = 0
f = 0
while io < len(new) - 1:
	if new[io] - new[io + 1] <= 1:
		rr.append(new[io])
		rr.append(new[io + 1])
		io += 2
		continue
	else:
		io += 1
if len(rr) >= 4:
	q = len(rr) % 4
	if q != 0:
		rr = rr[:-q]
	i = 0
	while i < len(rr):
		f += min(rr[i], rr[i + 1]) * min(rr[i + 2], rr[i + 3])
		i += 4
print(f)


from sys import stdin
n = int(input())
num = list(map(int, stdin.readline().split()))

def solve(n, num):
	nmax = 1000003
	cur = nmax * [0]
	pt = []
	res = 0
	for x in range(len(num)):
		cur[num[x]] += 1
	for i in range(nmax - 3, 1, -1):
		for j in range((cur[i + 1] % 2 + cur[i]) // 2):
			pt.append(i)
		if cur[i] > 0:
			cur[i] += cur[i + 1] % 2
	for i in range(1, len(pt), 2):
		res += pt[i - 1] * pt[i]
	return res
print(solve(n, num))


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)


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)


from sys import stdin
number_of_sticks = int(stdin.readline().rstrip('\n'))
second_line = stdin.readline().rstrip('\n')
sticks = [int(x) for x in second_line.split(' ')]

def execute(number_of_sticks, sticks):
	max = 0
	if number_of_sticks < 4:
		return max
	else:
		sticks.sort()
		sticks.reverse()
		current_max = 0
		i = 1
		while i < len(sticks):
			if sticks[i - 1] - sticks[i] <= 1:
				if current_max == 0:
					current_max = sticks[i]
					i += 1
				else:
					max += current_max * sticks[i]
					current_max = 0
					i += 1
			i += 1
		return max
print(execute(number_of_sticks, sticks))


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)
main()


x = int(input())
L = [int(i) for i in input().split()]
L.sort()
L = L[::-1]
a = 0
c = 0
A = []
while len(L) >= 2:
	if L[0] == L[1] or L[0] == L[1] + 1:
		A.append(L[1])
		L.pop(0)
		L.pop(0)
	else:
		L.pop(0)
try:
	while c < len(A):
		a += A[c] * A[c + 1]
		c += 2
	print(a)
except IndexError:
	print(a)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
res = 0
i = n - 1
b = []
while i > 0:
	if a[i] - a[i - 1] < 2:
		b.append(a[i - 1])
		i -= 1
	i -= 1
for i in range(0, len(b) - 1, 2):
	res += b[i] * b[i + 1]
print(res)


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter
main = Counter(arr)
for key in sorted(main.keys(), reverse=True):
	if main[key] % 2:
		main[key] -= 1
		if key - 1 in main:
			main[key - 1] += 1
total = 0
f = []
for key in sorted(main.keys(), reverse=True):
	while main[key]:
		f.append(key)
		main[key] -= 1
		if len(f) == 4:
			total += f[0] * f[2]
			f = []
print(total)


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)


__author__ = 'Dmitry Petrushin'
__version__ = '3.4'
from sys import stdin as inp

def rectangles(lengths):
	n_max = 10 ** 6 + 2
	sticks = [0 for _ in range(n_max)]
	tmp = list()
	for length in lengths:
		sticks[length] += 1
	for i in range(n_max - 2, 1, -1):
		for _ in range((sticks[i + 1] % 2 + sticks[i]) // 2):
			tmp.append(i)
		if sticks[i] > 0:
			sticks[i] += sticks[i + 1] % 2
	result = 0
	for i in range(1, len(tmp), 2):
		result += tmp[i - 1] * tmp[i]
	return result

def main():
	N = inp.readline()
	lengths = list(map(int, inp.readline().split()))
	print(rectangles(lengths))
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ans = 1
f = 0
i = n - 1
anss = 0
while i > 0:
	if i > 0 and arr[i] == arr[i - 1]:
		ans *= arr[i]
		i -= 2
		f += 1
	elif i > 0 and arr[i - 1] == arr[i] - 1:
		ans *= arr[i - 1]
		f += 1
		i -= 2
	else:
		i -= 1
	if f == 2:
		anss += ans
		ans = 1
		f = 0
if anss != 0:
	print(anss)
else:
	print(0)


n = int(input())
sticks = sorted(map(int, input().split()), key=lambda x: -x)
area = 0
pairs = []
pos = 0
while pos < n - 1:
	(a, b) = (sticks[pos], sticks[pos + 1])
	if a - b <= 1:
		if len(pairs) == 0:
			pairs.append(b)
		else:
			area += pairs.pop() * b
		pos += 1
	pos += 1
print(area)


n = int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
ans = 0
area = 0
ignore_next = False
for i in range(n - 1):
	if ignore_next:
		ignore_next = False
		continue
	l1 = l[i]
	l2 = l[i + 1]
	length = 0
	if l1 == l2:
		length = l1
	elif l1 == l2 + 1:
		length = l1 - 1
	if length:
		if area:
			ans += area * length
			area = 0
		else:
			area = length
		ignore_next = True
print(ans)


n = int(input())
answer = 0
sticks = input().split()
for i in range(n):
	sticks[i] = int(sticks[i])
sticks.sort(reverse=True)
i = 0
v = []
while i < n - 1:
	if abs(sticks[i] - sticks[i + 1]) < 2:
		v.append(min(sticks[i], sticks[i + 1]))
		i += 2
	else:
		i += 1
v.sort(reverse=True)
i = 0
while i < len(v) - 1:
	answer += v[i] * v[i + 1]
	i += 2
print(answer)


(n, l) = (int(input()), list(map(int, input().split())))
l.sort(reverse=True)
ans = 0
size = []
i = 0
while i < n - 1:
	if l[i] - l[i + 1] <= 1:
		size.append(l[i + 1])
		i += 2
	else:
		i += 1
for index in range(len(size) // 2):
	ans += size[2 * index] * size[2 * index + 1]
print(ans)


n = int(input())
s = input()
a = []
for x in s.split(' '):
	a.append(int(x))
a.sort()
ans = 0
k = 0
flag = 0
for i in range(n - 1, 0, -1):
	if flag:
		flag = 0
		continue
	if a[i] == a[i - 1] or a[i] == a[i - 1] + 1:
		if k != 0:
			ans += k * a[i - 1]
			k = 0
		else:
			k = a[i - 1]
		flag = 1
print(ans)


n = int(input())
rects = [int(s) for s in input().split()]
rects.sort()
sumsquare = 0
stash = []
i = len(rects) - 1
while i > 0:
	if rects[i] - rects[i - 1] == 1 or rects[i] == rects[i - 1]:
		if len(stash) == 2:
			sumsquare += stash[0] * stash[1]
			stash.clear()
		stash.append(rects[i - 1])
		rects.pop()
		rects.pop()
		i -= 2
	else:
		i -= 1
if len(stash) == 2:
	sumsquare += stash[0] * stash[1]
	stash.clear()
print(sumsquare)


n = int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
a = []
i = 0
while i < len(l) - 1:
	if l[i] == l[i + 1]:
		a.append(l[i])
		i += 2
	elif l[i] == l[i + 1] + 1:
		a.append(l[i] - 1)
		i += 2
	else:
		i += 1
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())
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)


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())
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)


from sys import stdin, stdout

def rectangular(n, array):
	sum = 0
	i = n - 2
	crutch = 0
	if n < 4:
		return 0
	array.sort()
	while i > -1:
		if array[i + 1] - array[i] <= 1:
			if crutch == 0:
				crutch = array[i]
				i -= 1
			else:
				sum += crutch * array[i]
				crutch = 0
				i -= 1
		i -= 1
	return sum
n = int(stdin.readline())
array = [int(i) for i in stdin.readline().split()]
print(rectangular(n, array))


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())
a = sorted((int(x) for x in input().split()))
p = []
ans = 0
while n >= 2:
	if a[n - 1] - a[n - 2] <= 1:
		p.append(a[n - 2])
		n -= 2
	else:
		n -= 1
n = len(p)
for (x, y) in zip(p[::2], p[1::2]):
	ans += x * y
print(ans)


from collections import Counter
n = int(input())
v = list(map(int, input().split()))
temp = dict(Counter(v))
rec = []
for (item1, item2) in temp.items():
	l_temp = []
	l_temp.append(item1)
	l_temp.append(item2)
	rec.append(l_temp)
rec.sort(reverse=True)
ans = 0
for i in range(0, len(rec)):
	if rec[i][1] % 2 != 0 and i + 1 < len(rec) and (rec[i][0] - 1 == rec[i + 1][0]):
		rec[i][1] -= 1
		rec[i + 1][1] += 1
	if rec[i][1] % 2 != 0:
		rec[i][1] -= 1
fin = []
for i in range(0, len(rec)):
	if rec[i][1] >= 2:
		fin.append([rec[i][0], rec[i][1]])
for i in range(0, len(fin)):
	ans += fin[i][1] // 4 * fin[i][0] * fin[i][0]
	fin[i][1] -= fin[i][1] // 4 * 4
	if fin[i][1] == 2 and i + 1 < len(fin):
		ans += fin[i][0] * fin[i + 1][0]
		fin[i + 1][1] -= 2
print(ans)


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)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = li()
	a.sort(reverse=True)
	ans = 0
	i = 0
	l = 0
	b = 0
	while i < n - 1:
		if a[i] == a[i + 1]:
			if not l:
				l = a[i]
			else:
				ans += l * a[i]
				l = 0
			i += 2
		elif a[i] == a[i + 1] + 1:
			a[i] -= 1
		else:
			i += 1
	print(ans)
for _ in range(1):
	case()


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
s1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s2 = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(1):
	n = inin()
	l = ain()
	l = sorted(l, reverse=True)
	ans = []
	f = [0] * n
	for i in range(0, n):
		if i < n - 1:
			if l[i] - l[i + 1] <= 1 and (f[i], f[i + 1]) == (0, 0):
				ans.append(l[i + 1])
				(f[i], f[i + 1]) = (1, 1)
	s = 0
	for i in range(0, len(ans) - 1, 2):
		s += ans[i] * ans[i + 1]
	print(s)


n = int(input())
lis = sorted(map(int, input().split()))
fi = se = ans = 0
i = n - 1
while i > 0:
	if fi == 0:
		if lis[i] == lis[i - 1]:
			fi = lis[i]
			i -= 1
		elif lis[i] == lis[i - 1] + 1:
			fi = lis[i - 1]
			i -= 1
	elif se == 0:
		if lis[i] == lis[i - 1]:
			se = lis[i]
			i -= 1
		elif lis[i] == lis[i - 1] + 1:
			se = lis[i - 1]
			i -= 1
	i -= 1
	if fi > 0 and se > 0:
		ans += fi * se
		fi = 0
		se = 0
print(ans)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
l = l[::-1]
k = 0
b = -1
for i in range(n - 1):
	if l[i] == l[i + 1] and b == -1:
		b = l[i]
		l[i + 1] = -1
	if l[i] == l[i + 1] and b != -1:
		k += b * l[i]
		b = -1
		l[i + 1] = -1
	if l[i] == l[i + 1] + 1 and b == -1:
		b = l[i] - 1
		l[i + 1] = -1
	if l[i] == l[i + 1] + 1 and b != -1:
		k += b * (l[i] - 1)
		b = -1
		l[i + 1] = -1
print(k)


n = int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
k = []
i = 1
while i < n:
	if l[i - 1] - l[i] == 1:
		k.append(l[i])
		i += 1
	elif l[i - 1] == l[i]:
		k.append(l[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())
lst = [*map(int, input().split())]
lst = [*reversed(sorted(lst))]
(count, res) = (1, [])
ex = res.extend
for (i, x) in enumerate(lst[1:]):
	if lst[i] == x:
		count += 1
	else:
		(div, mod) = (count // 2, count % 2)
		ex([lst[i]] * div)
		count = 1
		if mod == 1 and lst[i] - x == 1:
			count += 1
		last = lst[i]
ex([lst[-1]] * (count // 2))
result = 0
for i in range(1, len(res), 2):
	result += res[i] * res[i - 1]
print(result)


from collections import *
from operator import itemgetter
from copy import deepcopy

def remove():
	tem = deepcopy(sorted(c.keys(), reverse=True))
	for i in tem:
		if c[i] % 4 in [1, 3]:
			c[i] -= 1
			if c[i - 1]:
				c[i - 1] += 1
			if c[i] == 0:
				del c[i]

def even():
	global ans
	all = deepcopy(sorted(c.keys(), reverse=True))
	for i in range(len(all)):
		ans += all[i] * all[i] * (c[all[i]] // 4)
		if c[all[i]] % 4 and i < len(all) - 1:
			ans += all[i] * all[i + 1]
			c[all[i + 1]] -= 2

def solve():
	global ans
	remove()
	even()
	return ans
(n, a) = (int(input()), list(map(int, input().split())))
(c, all, ans) = (Counter(a), deque([]), 0)
print(solve())


n = int(input())
ai = list(map(int, input().split()))
ai.sort()
ans = 0
prev = 0
sticks = []
i = n - 2
while i > -1:
	if ai[i + 1] <= ai[i] + 1:
		sticks += [ai[i]]
		i -= 1
	i -= 1
for i in range(1, len(sticks), 2):
	ans += sticks[i] * sticks[i - 1]
print(ans)


m = {}
n = int(input())
data = input().split()
for i in data:
	if -int(i) not in m:
		m[-int(i)] = 1
	else:
		m[-int(i)] += 1
ant = 0
ans = 0
for i in sorted(m):
	if m[i] > 1:
		if ant != 0:
			ans += ant * i
			m[i] -= 2
			ant = 0
	ans += m[i] // 4 * (i * i)
	m[i] %= 4
	if m[i] > 1:
		if ant == 0:
			ant = i
		else:
			ans += i * ant
			ant = 0
	if m[i] % 2 == 1 and i + 1 in m:
		m[i + 1] += 1
print(ans)


import sys
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(0)
	sys.exit()
a.sort(reverse=True)
d = {}
i = 1
while i < len(a):
	if a[i] == a[i - 1] or a[i] == a[i - 1] - 1:
		if a[i] not in d:
			d[a[i]] = 0
		d[a[i]] += 2
		a[i] = 0
		a[i - 1] = 0
	i += 1
st = []
for i in d:
	st.append([i, d[i]])
if len(st) == 0:
	print(0)
	sys.exit()
ans = st[0][0] * st[0][0] * (st[0][1] // 4)
st[0][1] = st[0][1] % 4
i = 1
while i < len(st):
	if st[i - 1][1] != 0:
		ans += st[i - 1][0] * st[i][0]
		st[i - 1][1] -= 2
		st[i][1] -= 2
	ans += st[i][0] * st[i][0] * (st[i][1] // 4)
	st[i][1] = st[i][1] % 4
	i += 1
print(ans)


import collections, itertools, functools, math

def solve():
	n = int(input())
	a = list(sorted(map(int, input().split())))
	pairs = collections.Counter()
	for i in range(n - 1, 0, -1):
		if a[i] is None:
			continue
		if a[i] == a[i - 1] or a[i] - 1 == a[i - 1]:
			pairs[a[i - 1]] += 1
			a[i] = None
			a[i - 1] = None
	pairs = sorted(pairs.items(), reverse=True)
	area = 0
	curr = None
	for p in pairs:
		p = list(p)
		if curr is not None:
			area += curr[0] * p[0]
			p[1] -= 1
			curr = None
		c = p[1] // 2
		if c > 0:
			area += p[0] * p[0] * c
		if p[1] % 2 != 0:
			curr = p
	return area
print(solve())


n = int(input())
lst = [*map(int, input().split())]
lst = [*reversed(sorted(lst))]
(res, first) = ([], 1)
ex = res.extend
for (i, x) in enumerate(lst[1:]):
	if x != lst[0]:
		break
	first += 1
(div, mod) = (first // 2, first % 2)
ex([lst[0]] * div)
(prev, elem) = (mod, lst[0])
count = 1
if n > first:
	item = lst[first]
	for (i, x) in enumerate(lst[first + 1:]):
		if item == x:
			count += 1
		else:
			(div, mod) = (count // 2, count % 2)
			if elem - item == 1:
				if prev == 1 and mod == 1:
					div += 1
					prev = 0
				else:
					prev = max(mod, prev)
			else:
				prev = mod
			ex([item] * div)
			(elem, item, count) = (item, x, 1)
	(div, mod) = (count // 2, count % 2)
	if elem - item == 1:
		if prev == 1 and mod == 1:
			div += 1
	ex([item] * div)
result = 0
for i in range(1, len(res), 2):
	result += res[i] * res[i - 1]
print(result)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
count = 0
temp = 1
i = 0
while i < n - 1:
	if l[i] == l[i + 1]:
		temp *= l[i]
		i += 2
		count += 1
	elif l[i] == l[i + 1] + 1:
		temp *= l[i + 1]
		i += 2
		count += 1
	else:
		i += 1
	if count == 2:
		count = 0
		ans += temp
		temp = 1
print(ans)


from sys import stdin, stdout
__author__ = 'vks'
n = int(stdin.readline())
sticks = [int(i) for i in stdin.readline().split()]
sticks.sort()
square = 0
n -= 1
while n > 0:
	a = 0
	b = 0
	while n > 0 and abs(sticks[n] - sticks[n - 1]) > 1:
		n -= 1
	if n > 0:
		a = min(sticks[n], sticks[n - 1])
	n -= 2
	while n > 0 and abs(sticks[n] - sticks[n - 1]) > 1:
		n -= 1
	if n > 0:
		b = min(sticks[n], sticks[n - 1])
	n -= 2
	square += a * b
stdout.write(str(square) + '\n')


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)


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)


am = int(input())
arr = list(map(int, input().split()))
arr.sort()
counted = [0] * 1000000
for i in range(am):
	counted[arr[i] - 1] += 1
fl = True
l = 0
lAdded = 0
haveL = []
haveAm = []
for i in range(len(counted) - 1, -1, -1):
	if counted[i] != 0:
		if fl:
			haveL += [i, i - 1]
			haveAm += [counted[i] - counted[i] % 2, counted[i] % 2]
			l = i
			lAdded = counted[i] % 2
			fl = False
		elif l - i == 1:
			haveL += [i - 1]
			haveAm[-1] += counted[i]
			if haveAm[-1] % 2 == 1:
				haveAm[-1] -= 1
				haveAm += [1]
			else:
				haveAm += [0]
			l = i
		else:
			haveL += [i, i - 1]
			haveAm += [counted[i] - counted[i] % 2, counted[i] % 2]
			l = i
haveTot = []
for i in range(len(haveL)):
	if haveAm[i] != 0:
		haveTot += [haveL[i] + 1] * (haveAm[i] // 2)
totArea = 0
haveTot.sort(reverse=True)
for i in range(0, len(haveTot) // 2 * 2, 2):
	totArea += haveTot[i] * haveTot[i + 1]
print(totArea)


n = int(input())
arr = sorted(list(map(int, input().split())))
(p, res) = ([], 0)
while n >= 2:
	if arr[n - 1] - arr[n - 2] <= 1:
		p.append(arr[n - 2])
		n -= 2
	else:
		n -= 1
for i in range(0, len(p) - 1, 2):
	res += p[i] * p[i + 1]
print(res)


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)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
i = 0
ans = []
while i < n:
	if i < n - 1 and l[i] - l[i + 1] <= 1:
		ans.append(l[i + 1])
		i += 1
	i += 1
tem = len(ans)
if tem <= 1:
	print(0)
else:
	i = 0
	s = 0
	while i < tem - 1:
		s += ans[i] * ans[i + 1]
		i += 2
	print(s)


n = int(input())
lst = []
lst.extend(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)


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)


from sys import stdin, stdout
from collections import Counter
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def fn(p1):
	global ans
	mx = smx = 0
	p = p11 = -1
	for i in range(p1 - 1, -1, -1):
		if i - 1 >= 0 and a[i] == a[i - 1]:
			mx = a[i]
			p = i
			break
		if i - 1 >= 0 and a[i] - a[i - 1] == 1:
			mx = a[i - 1]
			p = i
			break
	for i in range(p - 2, -1, -1):
		if i - 1 >= 0 and a[i] == a[i - 1]:
			smx = a[i]
			p11 = i
			break
		if i - 1 >= 0 and a[i] - a[i - 1] == 1:
			smx = a[i - 1]
			p11 = i
			break
	ans += mx * smx
	return p11 - 1
for _ in range(1):
	n = nmbr()
	a = sorted(lst())
	mx = smx = ans = 0
	p1 = n
	while p1 >= 0:
		p1 = fn(p1)
	print(ans)


n = int(input())
a = [-1]
a += [int(x) for x in input().split()]
a.sort()
l = 0
ans = 0
i = n
while i >= 1:
	if a[i] == a[i - 1] or a[i] == a[i - 1] + 1:
		if l == 0:
			l = a[i - 1]
		else:
			ans += l * a[i - 1]
			l = 0
		i -= 2
	else:
		i -= 1
print(ans)


def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = []
	area = 0
	a.sort()
	for i in reversed(range(len(a))):
		if i > 0 and (a[i] == a[i - 1] or a[i] - 1 == a[i - 1]):
			b.append(a[i - 1])
			a[i - 1] = -1
	for i in range(int(len(b) / 2)):
		area += b[2 * i] * b[2 * i + 1]
	print(area)
main()


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))

def printDivisors(n):
	divisors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				divisors.append(i)
			else:
				divisors.extend((i, n // i))
		i = i + 1
	return divisors

def countTotalBits(num):
	binary = bin(num)[2:]
	return len(binary)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
ans = 0
count = 0
n = vary(1)
num = sorted(array_int(), reverse=True)
pt = []
i = 1
while i < n:
	if num[i - 1] - num[i] == 0:
		pt.append(num[i])
		i += 2
	elif num[i - 1] - num[i] == 1:
		pt.append(num[i])
		i += 2
	else:
		i += 1
for i in range(1, len(pt), 2):
	ans += pt[i - 1] * pt[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
m = 0
total = 0
while True:
	flag1 = False
	flag2 = False
	for i in range(m, n - 1):
		if (a[i] == a[i + 1] or a[i] - a[i + 1] == 1) and a[i] != -1:
			flag1 = True
			x = a[i + 1]
			m = i + 2
			break
	for i in range(m, n - 1):
		if (a[i] == a[i + 1] or a[i] - a[i + 1] == 1) and a[i] != -1:
			flag2 = True
			y = a[i + 1]
			m = i + 2
			break
	if flag2 == True:
		total += x * y
	else:
		break
print(total)


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)


n = int(input())
a = [int(i) for i in input().split()]
g = []
s = 0
a.sort(reverse=True)
i = 0
while i < len(a) - 1:
	if a[i] == a[i + 1] or a[i] == a[i + 1] + 1:
		g.append(a[i + 1])
		del a[i]
		del a[i]
	else:
		del a[i]
g.sort()
if len(g) < 2:
	print(0)
elif len(g) % 2 != 0:
	del g[0]
	j = 0
	while j < len(g) - 1:
		s += g[j] * g[j + 1]
		j += 2
	print(s)
else:
	j = 0
	while j < len(g) - 1:
		s += g[j] * g[j + 1]
		j += 2
	print(s)


from functools import reduce
from operator import *
from math import *
from sys import *
from string import *
setrecursionlimit(10 ** 7)
RI = lambda : list(map(int, input().split()))
RS = lambda : input().rstrip().split()
n = RI()[0]
l = RI()
l.sort(reverse=True)
ans = 0
pre = 0
i = 0
while i < len(l) - 1:
	if l[i] - l[i + 1] <= 1:
		if pre:
			ans += pre * l[i + 1]
			pre = 0
		else:
			pre = l[i + 1]
		i += 1
	i += 1
print(ans)


from sys import stdin
import functools
import math

def read():
	return map(int, stdin.readline().split())
read()
a = sorted(list(read()))
b = []
while len(a) > 1:
	if a[-1] - a[-2] == 0:
		b.append(a.pop())
	elif a[-1] - a[-2] == 1:
		b.append(a.pop() - 1)
	a.pop()
b = list(reversed(b))
ans = 0
while len(b) > 1:
	ans += b[-1] * b[-2]
	b.pop()
	b.pop()
print(ans)


import sys

def max_square(number_of_sticks, sticks):
	if number_of_sticks < 4:
		return 0
	else:
		sticks.sort()
		sticks.reverse()
		max_sq = 0
		max_stick = 0
		i = 1
		while i < len(sticks):
			if sticks[i - 1] - sticks[i] <= 1:
				if max_stick == 0:
					max_stick = sticks[i]
					i += 1
				else:
					max_sq += max_stick * sticks[i]
					max_stick = 0
					i += 1
			i += 1
		return max_sq
first_line = int(sys.stdin.readline())
second_line = [int(i) for i in sys.stdin.readline().split()]
sys.stdout.write(str(max_square(first_line, second_line)))


def main():
	input()
	(res, it) = (0, iter(sorted(map(int, input().split()), reverse=True)))
	try:
		while True:
			(a, b, c, d) = (next(it), next(it), next(it), next(it))
			while a > b + 1:
				(a, b, c, d) = (b, c, d, next(it))
			while c > d + 1:
				(c, d) = (d, next(it))
			res += b * d
	except StopIteration:
		print(res)
main()


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 = 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)


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)


from __future__ import print_function
from collections import *
from sys import stdin
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
a = gil()
a.sort()
length = []
ans = 0
while len(a) > 1:
	if a.pop() - a[-1] <= 1:
		length.append(a.pop())
for i in range(0, len(length), 2):
	if i + 1 < len(length):
		ans += length[i] * length[i + 1]
print(ans)


n = int(input())
c = [0] * 1000001
m = 0
for i in list(map(int, input().split())):
	c[i] += 1
	if i > m:
		m = i
n = m
while m != 1:
	if c[m] % 2 == 1:
		if c[m - 1]:
			c[m] -= 1
			c[m - 1] += 1
		else:
			c[m] -= 1
	m -= 1
pos = 0
s = 0
mem = 0
for pos in range(n, 0, -1):
	if mem and c[pos] >= 2:
		c[pos] -= 2
		s += pos * mem
		mem = 0
	s += pos * pos * (c[pos] // 4)
	if c[pos] % 4 >= 2:
		mem = pos
print(s)


n = int(input())
arr = list(sorted(map(int, input().split()), reverse=True))
dstick = list()
idx = 0
while idx + 1 < n:
	if arr[idx] == arr[idx + 1] or arr[idx] - 1 == arr[idx + 1]:
		dstick.append(arr[idx + 1])
		idx += 2
	else:
		idx += 1
if len(dstick) & 1 == 1:
	dstick.pop()
ans = 0
for i in range(0, len(dstick) - 1, 2):
	ans += dstick[i] * dstick[i + 1]
print(ans)


_ = 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)


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())
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)


(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)


(x, y) = (0, 0)
n = int(input())
n -= 1
l = list(map(int, input().split()))
l.sort()
t = 0
while n > 0:
	if l[n] - l[n - 1] <= 1:
		if not x:
			x = l[n] - l[n] + l[n - 1]
			n -= 1
		else:
			y = l[n] - l[n] + l[n - 1]
			t += x * y
			(x, y) = (0, 0)
			n -= 1
	n -= 1
print(t)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
rect = []
i = 0
while i < n:
	if i + 1 < n and l[i] == l[i + 1]:
		rect.append(l[i])
		i += 2
	elif i + 1 < n and l[i] - 1 == l[i + 1]:
		rect.append(l[i + 1])
		i += 2
	else:
		i += 1
s = 0
for i in range(0, len(rect), 2):
	if i + 1 < len(rect):
		s += rect[i] * rect[i + 1]
print(s)


import collections
n = int(input())
nums = list(map(int, input().split()))
d = collections.defaultdict(int)
for i in nums:
	d[i] += 1
keys = sorted(d, reverse=True)
for k in keys:
	if d[k] % 2:
		if d[k - 1] > 0:
			d[k] -= 1
			d[k - 1] += 1
		else:
			d[k] -= 1
count = keys[0]
i = 0
ans = collections.defaultdict(list)
while count:
	if d[count] > 0:
		d[count] -= 2
		ans[i] = ans[i] + [count, count]
	if len(ans[i]) == 4:
		i += 1
	if d[count] == 0:
		count -= 1
area = 0
for i in ans:
	if len(ans[i]) == 4:
		area = area + ans[i][0] * ans[i][2]
print(area)


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)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = sorted(array(), reverse=True)
l = []
i = 0
ans = 0
while i + 1 < n:
	if a[i] - a[i + 1] <= 1:
		l.append(a[i + 1])
		i += 1
	i += 1
i = 0
while i + 1 < len(l):
	ans += l[i] * l[i + 1]
	i += 2
print(ans)