import collections

s = set()

N = int(eval(input()))

count = []*(10**9+1)

ma1 = 0

ma2 = 0

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

a = collections.Counter(A)

b = sorted(list(a.items()),reverse = True)



for i in b:

  if ma1 == 0 and i[1] > 1:

    ma1 = i[0]

    if i[1] > 3:

      ma2 = i[0]

  elif ma1 != 0 and i[1] > 1:

    ma2 = i[0]

  if ma1 > 0 and ma2 > 0:

    break

  

print((ma1*ma2))

    
N = int(eval(input()))

ma1 = 0

ma2 = 0

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

A.append(0)

a = sorted(A,reverse = True)



hold = 0

count = 0



for i in a:

  if i == hold:

    count += 1

  else:

    if count > 3 and ma1 == 0:

      ma1 = hold

      ma2 = hold

    elif count > 1:

      if ma1 == 0:

        ma1 = hold

      elif ma2 == 0:

        ma2 = hold

    hold = i

    count = 1

    if ma1 != 0 and ma2 != 0:

      break

    



print((ma1*ma2))

    

import collections

s = set()
N = int(eval(input()))
count = [] * (10**9 + 1)
ma1 = 0
ma2 = 0
A = list(map(int, input().split()))
a = collections.Counter(A)
b = sorted(list(a.items()), reverse=True)
for i in b:
    if ma1 == 0 and i[1] > 1:
        ma1 = i[0]
        if i[1] > 3:
            ma2 = i[0]
    elif ma1 != 0 and i[1] > 1:
        ma2 = i[0]
    if ma1 > 0 and ma2 > 0:
        break
print((ma1 * ma2))

N = int(eval(input()))
ma1 = 0
ma2 = 0
A = list(map(int, input().split()))
A.append(0)
a = sorted(A, reverse=True)
hold = 0
count = 0
for i in a:
    if i == hold:
        count += 1
    else:
        if count > 3 and ma1 == 0:
            ma1 = hold
            ma2 = hold
        elif count > 1:
            if ma1 == 0:
                ma1 = hold
            elif ma2 == 0:
                ma2 = hold
        hold = i
        count = 1
        if ma1 != 0 and ma2 != 0:
            break
print((ma1 * ma2))

-import collections - -s = set() -count = [] * (10**9 + 1) -a = collections.Counter(A) -b = sorted(list(a.items()), reverse=True) -for i in b: -    if ma1 == 0 and i[1] > 1: -        ma1 = i[0] -        if i[1] > 3: -            ma2 = i[0] -    elif ma1 != 0 and i[1] > 1: -        ma2 = i[0] -    if ma1 > 0 and ma2 > 0: -        break +A.append(0) +a = sorted(A, reverse=True) +hold = 0 +count = 0 +for i in a: +    if i == hold: +        count += 1 +    else: +        if count > 3 and ma1 == 0: +            ma1 = hold +            ma2 = hold +        elif count > 1: +            if ma1 == 0: +                ma1 = hold +            elif ma2 == 0: +                ma2 = hold +        hold = i +        count = 1 +        if ma1 != 0 and ma2 != 0: +            break