from collections import Counter

def main():

    n = int(eval(input()))

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

    c = Counter(A)

    l1, l2 = 0, 0

    for k, v in list(c.items()):

        if k > l1:

            if v >= 4:

                l1, l2 = k, k

            elif 2 <= v <= 3:

                l1, l2 = k, l1

            else:

                pass

        elif l2 < k <= l1 and v >= 2:

            l2 = k

    print((l1 * l2)) 



if __name__ == '__main__':

    main()

from collections import Counter

def main():

    n = int(eval(input()))

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

    c = Counter(A)

    B = sorted([(k, v) for k, v in list(c.items()) if v >= 2], reverse = True, key = lambda x: x[0])

    if len(B) < 2:

        print((0))

    elif B[0][1] >= 4:

        print((B[0][0] ** 2))

    else:

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



if __name__ == '__main__':

    main()

from collections import Counter


def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    c = Counter(A)
    l1, l2 = 0, 0
    for k, v in list(c.items()):
        if k > l1:
            if v >= 4:
                l1, l2 = k, k
            elif 2 <= v <= 3:
                l1, l2 = k, l1
            else:
                pass
        elif l2 < k <= l1 and v >= 2:
            l2 = k
    print((l1 * l2))


if __name__ == "__main__":
    main()

from collections import Counter


def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    c = Counter(A)
    B = sorted(
        [(k, v) for k, v in list(c.items()) if v >= 2], reverse=True, key=lambda x: x[0]
    )
    if len(B) < 2:
        print((0))
    elif B[0][1] >= 4:
        print((B[0][0] ** 2))
    else:
        print((B[0][0] * B[1][0]))


if __name__ == "__main__":
    main()

-    l1, l2 = 0, 0 -    for k, v in list(c.items()): -        if k > l1: -            if v >= 4: -                l1, l2 = k, k -            elif 2 <= v <= 3: -                l1, l2 = k, l1 -            else: -                pass -        elif l2 < k <= l1 and v >= 2: -            l2 = k -    print((l1 * l2)) +    B = sorted( +        [(k, v) for k, v in list(c.items()) if v >= 2], reverse=True, key=lambda x: x[0] +    ) +    if len(B) < 2: +        print((0)) +    elif B[0][1] >= 4: +        print((B[0][0] ** 2)) +    else: +        print((B[0][0] * B[1][0]))