from collections import Counter

n = int(eval(input()))

a = list(map(int, input().split()))



count = Counter(a)

ans = [0]*2

t = 0

for i in sorted(list(count.items()), reverse=True):

  if i[1] >= 4:

    if t == 0:

      ans[0],ans[1] = i[0],i[0]

      t = 2

    elif t == 1:

      ans[t] = i[0]

      t += 1

  elif i[1] >= 2:

    ans[t] = i[0]

    t += 1

  if t == 2: break

print((ans[0]*ans[1]))
n = int(eval(input()))

a = list(map(int, input().split()))



d = {}

for i in a:

  if i in d: d[i] += 1

  else: d[i] = 1



t = 0

ans = []

for k,v in sorted(list(d.items()), key=lambda x: x[0], reverse=True):

  if v >= 4 and t == 0:

    print((k*k))

    exit()

  elif v >= 2:

    ans.append(k)

    t += 1

  if t == 2:

    print((ans[0]*ans[1]))

    exit()

print((0))
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
count = Counter(a)
ans = [0] * 2
t = 0
for i in sorted(list(count.items()), reverse=True):
    if i[1] >= 4:
        if t == 0:
            ans[0], ans[1] = i[0], i[0]
            t = 2
        elif t == 1:
            ans[t] = i[0]
            t += 1
    elif i[1] >= 2:
        ans[t] = i[0]
        t += 1
    if t == 2:
        break
print((ans[0] * ans[1]))

n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
t = 0
ans = []
for k, v in sorted(list(d.items()), key=lambda x: x[0], reverse=True):
    if v >= 4 and t == 0:
        print((k * k))
        exit()
    elif v >= 2:
        ans.append(k)
        t += 1
    if t == 2:
        print((ans[0] * ans[1]))
        exit()
print((0))

-from collections import Counter - -count = Counter(a) -ans = [0] * 2 +d = {} +for i in a: +    if i in d: +        d[i] += 1 +    else: +        d[i] = 1 -for i in sorted(list(count.items()), reverse=True): -    if i[1] >= 4: -        if t == 0: -            ans[0], ans[1] = i[0], i[0] -            t = 2 -        elif t == 1: -            ans[t] = i[0] -            t += 1 -    elif i[1] >= 2: -        ans[t] = i[0] +ans = [] +for k, v in sorted(list(d.items()), key=lambda x: x[0], reverse=True): +    if v >= 4 and t == 0: +        print((k * k)) +        exit() +    elif v >= 2: +        ans.append(k) -        break -print((ans[0] * ans[1])) +        print((ans[0] * ans[1])) +        exit() +print((0))