from collections import Counter





N = int(eval(input()))

c = Counter(list(map(int, input().split())))

usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])

if len(usables) <= 1:

    print((0))

else:

    if usables[-1][1] >= 4:

        print((usables[-1][0] ** 2))

    else:

        print((usables[-1][0] * usables[-2][0]))

from collections import Counter





def solve():

    N = int(eval(input()))

    c = Counter(list(map(int, input().split())))

    usables = sorted([k for k, v in list(c.items()) if v > 1])



    if len(usables) == 0:

        return 0

    else:

        ans = usables[-1]

        if c[ans] > 3:

            return ans ** 2

        elif len(usables) > 1:

            usables.pop()

            return ans * usables[-1]

        else:

            return 0





print((solve()))

from collections import Counter

N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])
if len(usables) <= 1:
    print((0))
else:
    if usables[-1][1] >= 4:
        print((usables[-1][0] ** 2))
    else:
        print((usables[-1][0] * usables[-2][0]))

from collections import Counter


def solve():
    N = int(eval(input()))
    c = Counter(list(map(int, input().split())))
    usables = sorted([k for k, v in list(c.items()) if v > 1])
    if len(usables) == 0:
        return 0
    else:
        ans = usables[-1]
        if c[ans] > 3:
            return ans**2
        elif len(usables) > 1:
            usables.pop()
            return ans * usables[-1]
        else:
            return 0


print((solve()))

-N = int(eval(input())) -c = Counter(list(map(int, input().split()))) -usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2]) -if len(usables) <= 1: -    print((0)) -else: -    if usables[-1][1] >= 4: -        print((usables[-1][0] ** 2)) + +def solve(): +    N = int(eval(input())) +    c = Counter(list(map(int, input().split()))) +    usables = sorted([k for k, v in list(c.items()) if v > 1]) +    if len(usables) == 0: +        return 0 -        print((usables[-1][0] * usables[-2][0])) +        ans = usables[-1] +        if c[ans] > 3: +            return ans**2 +        elif len(usables) > 1: +            usables.pop() +            return ans * usables[-1] +        else: +            return 0 + + +print((solve()))