def main():

    import sys

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    import collections

    a = collections.Counter(a).most_common()

    a = sorted(a, key=lambda x: x[0], reverse=True)

    t = -1

    for k, v in a:

        if v >= 4:

            if t != -1:

                print((t * k))

                exit()

            else:

                print((k ** 2))

                exit()

        elif v >= 2:

            if t != -1:

                print((t * k))

                exit()

            else:

                t = k

    print((0))



if __name__ == '__main__':

    main()

def slove():

    import sys

    import collections

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True)

    ans = []

    for k, v in a:

        if v >= 2:

            for i in range(v // 2 * 2):

                ans.append(k)

        if len(ans) >= 4:

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

            exit()

    print((0))





if __name__ == '__main__':

    slove()

def main():
    import sys

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    import collections

    a = collections.Counter(a).most_common()
    a = sorted(a, key=lambda x: x[0], reverse=True)
    t = -1
    for k, v in a:
        if v >= 4:
            if t != -1:
                print((t * k))
                exit()
            else:
                print((k**2))
                exit()
        elif v >= 2:
            if t != -1:
                print((t * k))
                exit()
            else:
                t = k
    print((0))


if __name__ == "__main__":
    main()

def slove():
    import sys
    import collections

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True)
    ans = []
    for k, v in a:
        if v >= 2:
            for i in range(v // 2 * 2):
                ans.append(k)
        if len(ans) >= 4:
            print((ans[0] * ans[2]))
            exit()
    print((0))


if __name__ == "__main__":
    slove()

-def main(): +def slove(): +    import collections -    import collections - -    a = collections.Counter(a).most_common() -    a = sorted(a, key=lambda x: x[0], reverse=True) -    t = -1 +    a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True) +    ans = [] -        if v >= 4: -            if t != -1: -                print((t * k)) -                exit() -            else: -                print((k**2)) -                exit() -        elif v >= 2: -            if t != -1: -                print((t * k)) -                exit() -            else: -                t = k +        if v >= 2: +            for i in range(v // 2 * 2): +                ans.append(k) +        if len(ans) >= 4: +            print((ans[0] * ans[2])) +            exit() -    main() +    slove()