def main():

    N = int(input())

    A = [int(i) for i in input().split()]

    from collections import Counter

    c = Counter(A)

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

    li.sort(reverse=True)

    if li and li[0][1] >= 4:

        return print(li[0][0] * li[0][0])

    elif len(li) <= 1:

        return print(0)

    else:

        return print(li[0][0] * li[1][0])





if __name__ == '__main__':

    main()

def main():

    _ = int(eval(input()))

    A = [int(i) for i in input().split()]

    from collections import Counter

    c = Counter(A)

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

    li.sort(reverse=True)

    if li and li[0][1] >= 4:

        print((li[0][0] * li[0][0]))

    elif len(li) <= 1:

        print((0))

    else:

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





if __name__ == '__main__':

    main()

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter

    c = Counter(A)
    li = [(k, v) for k, v in c.items() if v >= 2]
    li.sort(reverse=True)
    if li and li[0][1] >= 4:
        return print(li[0][0] * li[0][0])
    elif len(li) <= 1:
        return print(0)
    else:
        return print(li[0][0] * li[1][0])


if __name__ == "__main__":
    main()

def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    from collections import Counter

    c = Counter(A)
    li = [(k, v) for k, v in list(c.items()) if v >= 2]
    li.sort(reverse=True)
    if li and li[0][1] >= 4:
        print((li[0][0] * li[0][0]))
    elif len(li) <= 1:
        print((0))
    else:
        print((li[0][0] * li[1][0]))


if __name__ == "__main__":
    main()

-    N = int(input()) +    _ = int(eval(input())) -    li = [(k, v) for k, v in c.items() if v >= 2] +    li = [(k, v) for k, v in list(c.items()) if v >= 2] -        return print(li[0][0] * li[0][0]) +        print((li[0][0] * li[0][0])) -        return print(0) +        print((0)) -        return print(li[0][0] * li[1][0]) +        print((li[0][0] * li[1][0]))