def main():

    N = int(input())

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

    from collections import Counter

    c = Counter(A)

    if (c.most_common()[0][1] < 2 or c.most_common()[1][1] < 2) \

            and c.most_common()[0][1] < 4:

        return print(0)

    d = [i[0] for i in c.items() if i[1] >= 2]

    if d:

        d.sort()

    e = [i[0] for i in c.items() if i[1] >= 4]

    if e:

        e.sort()

    if d and e:

        print(max(d[-1] * d[-2], e[-1]*e[-1]))

    elif d:

        print(d[-1] * d[-2])

    else:

        print(e[-1]*e[-1])





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

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

    from collections import Counter

    c = Counter(A)

    most = c.most_common()

    if most[0][1] >= 4:

        ans = []

        for k, v in most:

            if v >= 4:

                ans.append(k)

                ans.append(k)

            elif v >= 2:

                ans.append(k)

        ans.sort()

        print((ans[-1]*ans[-2]))

    elif most[0][1] >= 2 and most[1][1] >= 2:

        ans = []

        for k, v in most:

            if v >= 2:

                ans.append(k)

        ans.sort()

        print((ans[-1]*ans[-2]))

    else:

        print((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)
    if (c.most_common()[0][1] < 2 or c.most_common()[1][1] < 2) and c.most_common()[0][
        1
    ] < 4:
        return print(0)
    d = [i[0] for i in c.items() if i[1] >= 2]
    if d:
        d.sort()
    e = [i[0] for i in c.items() if i[1] >= 4]
    if e:
        e.sort()
    if d and e:
        print(max(d[-1] * d[-2], e[-1] * e[-1]))
    elif d:
        print(d[-1] * d[-2])
    else:
        print(e[-1] * e[-1])


if __name__ == "__main__":
    main()

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

    c = Counter(A)
    most = c.most_common()
    if most[0][1] >= 4:
        ans = []
        for k, v in most:
            if v >= 4:
                ans.append(k)
                ans.append(k)
            elif v >= 2:
                ans.append(k)
        ans.sort()
        print((ans[-1] * ans[-2]))
    elif most[0][1] >= 2 and most[1][1] >= 2:
        ans = []
        for k, v in most:
            if v >= 2:
                ans.append(k)
        ans.sort()
        print((ans[-1] * ans[-2]))
    else:
        print((0))


if __name__ == "__main__":
    main()

-    N = int(input()) +    N = int(eval(input())) -    if (c.most_common()[0][1] < 2 or c.most_common()[1][1] < 2) and c.most_common()[0][ -        1 -    ] < 4: -        return print(0) -    d = [i[0] for i in c.items() if i[1] >= 2] -    if d: -        d.sort() -    e = [i[0] for i in c.items() if i[1] >= 4] -    if e: -        e.sort() -    if d and e: -        print(max(d[-1] * d[-2], e[-1] * e[-1])) -    elif d: -        print(d[-1] * d[-2]) +    most = c.most_common() +    if most[0][1] >= 4: +        ans = [] +        for k, v in most: +            if v >= 4: +                ans.append(k) +                ans.append(k) +            elif v >= 2: +                ans.append(k) +        ans.sort() +        print((ans[-1] * ans[-2])) +    elif most[0][1] >= 2 and most[1][1] >= 2: +        ans = [] +        for k, v in most: +            if v >= 2: +                ans.append(k) +        ans.sort() +        print((ans[-1] * ans[-2])) -        print(e[-1] * e[-1]) +        print((0))