def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10000000)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations

    #from itertools import accumulate, product

    from bisect import bisect_left,bisect_right

    from math import floor, ceil

    #from operator import itemgetter



    #mod = 1000000007



    N = int(eval(input()))

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

    a = sorted(A, reverse=1)

    res1 = 0

    res2 = []

    for i in range(N-3):

        if a[i]==a[i+1]==a[i+2]==a[i+3]:

            res1 = a[i]

            break

    for i in range(N-1):

        if a[i]==a[i+1] and not a[i] in res2:

            res2.append(a[i])

        if len(res2)==2:

            break

    if len(res2)==0:

        print((0))

    elif len(res2)==1:

        print((res1**2))

    else:

        print((max(res1**2, res2[0]*res2[1])))







if __name__ == '__main__':

    main()
def main():

    import sys

    #input = sys.stdin.readline

    sys.setrecursionlimit(10000000)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations

    #from itertools import accumulate, product

    from bisect import bisect_left,bisect_right

    from math import floor, ceil

    #from operator import itemgetter



    #mod = 1000000007



    N = int(eval(input()))

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

    a = sorted(A, reverse=1)

    res1 = 0

    res2 = []

    for i in range(N-3):

        if a[i]==a[i+1]==a[i+2]==a[i+3]:

            res1 = a[i]

            break

    for i in range(N-1):

        if a[i]==a[i+1] and not a[i] in res2:

            res2.append(a[i])

        if len(res2)==2:

            break

    if len(res2)<2:

        print((res1**2))

    else:

        print((max(res1**2, res2[0]*res2[1])))







if __name__ == '__main__':

    main()
def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations

    # from itertools import accumulate, product
    from bisect import bisect_left, bisect_right
    from math import floor, ceil

    # from operator import itemgetter
    # mod = 1000000007
    N = int(eval(input()))
    A = list(map(int, input().split()))
    a = sorted(A, reverse=1)
    res1 = 0
    res2 = []
    for i in range(N - 3):
        if a[i] == a[i + 1] == a[i + 2] == a[i + 3]:
            res1 = a[i]
            break
    for i in range(N - 1):
        if a[i] == a[i + 1] and not a[i] in res2:
            res2.append(a[i])
        if len(res2) == 2:
            break
    if len(res2) == 0:
        print((0))
    elif len(res2) == 1:
        print((res1**2))
    else:
        print((max(res1**2, res2[0] * res2[1])))


if __name__ == "__main__":
    main()

def main():
    import sys

    # input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations

    # from itertools import accumulate, product
    from bisect import bisect_left, bisect_right
    from math import floor, ceil

    # from operator import itemgetter
    # mod = 1000000007
    N = int(eval(input()))
    A = list(map(int, input().split()))
    a = sorted(A, reverse=1)
    res1 = 0
    res2 = []
    for i in range(N - 3):
        if a[i] == a[i + 1] == a[i + 2] == a[i + 3]:
            res1 = a[i]
            break
    for i in range(N - 1):
        if a[i] == a[i + 1] and not a[i] in res2:
            res2.append(a[i])
        if len(res2) == 2:
            break
    if len(res2) < 2:
        print((res1**2))
    else:
        print((max(res1**2, res2[0] * res2[1])))


if __name__ == "__main__":
    main()

-    input = sys.stdin.readline +    # input = sys.stdin.readline -    if len(res2) == 0: -        print((0)) -    elif len(res2) == 1: +    if len(res2) < 2: