from sys import stdin



n, *a = list(map(int, stdin.read().split())) 



l_count = {}

for l in a:

    l_count.update({l: l_count.get(l, 0) + 1})

  

long_side, short_side = 0, 0

for l, c in sorted(list(l_count.items()), reverse=1):

    if c != 1:

        if not long_side:

            if c >= 4:

                print((l ** 2))

                exit()

            else:

                long_side = l

        else:

            short_side = l

            break



print((long_side * short_side))
import sys



n, *l = list(map(int, sys.stdin.read().split()))



def main():

    l.sort(reverse=True)



    a = b = 0

    i = 0

    while i <= n - 2:

        if l[i] == l[i+1]:

            if a:

                b = l[i]

                break

            else:

                a = l[i]

                i += 2

                continue

        i += 1

    

    return a * b



if __name__ == '__main__':

    ans = main()

    print(ans)
from sys import stdin

n, *a = list(map(int, stdin.read().split()))
l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
long_side, short_side = 0, 0
for l, c in sorted(list(l_count.items()), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print((l**2))
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break
print((long_side * short_side))

import sys

n, *l = list(map(int, sys.stdin.read().split()))


def main():
    l.sort(reverse=True)
    a = b = 0
    i = 0
    while i <= n - 2:
        if l[i] == l[i + 1]:
            if a:
                b = l[i]
                break
            else:
                a = l[i]
                i += 2
                continue
        i += 1
    return a * b


if __name__ == "__main__":
    ans = main()
    print(ans)

-from sys import stdin +import sys -n, *a = list(map(int, stdin.read().split())) -l_count = {} -for l in a: -    l_count.update({l: l_count.get(l, 0) + 1}) -long_side, short_side = 0, 0 -for l, c in sorted(list(l_count.items()), reverse=1): -    if c != 1: -        if not long_side: -            if c >= 4: -                print((l**2)) -                exit() +n, *l = list(map(int, sys.stdin.read().split())) + + +def main(): +    l.sort(reverse=True) +    a = b = 0 +    i = 0 +    while i <= n - 2: +        if l[i] == l[i + 1]: +            if a: +                b = l[i] +                break -                long_side = l -        else: -            short_side = l -            break -print((long_side * short_side)) +                a = l[i] +                i += 2 +                continue +        i += 1 +    return a * b + + +if __name__ == "__main__": +    ans = main() +    print(ans)