import collections

def main():



    n = int(eval(input()))

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

    cnt = collections.Counter(a)

    set_a = set(a)

    a = []

    a = list(set_a)

    a.sort(reverse=True)

    select = 0

    ans = 1

    tmp = 0

    flg = 0

    for i, aa in enumerate(a):

        if cnt[aa] >= 4 and flg == 0:

            tmp = aa * aa

            flg = 1

        if cnt[aa] >= 2:

            select += 1

            ans *= aa

        if select == 2:

            ans = max(tmp,ans)

            print(ans)

            return

    print((0))







if __name__ == '__main__':

    main()

import collections

def main():



    n = int(eval(input()))

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

    # a.sort(reverse=True)

    c = collections.Counter(a)

    cl = c.most_common()

    # cl.sort(reverse = True)

    cnt = 1

    lst = []

    now = a[0]

    ans = 0

    for i, cc in enumerate(cl):

        if cc[1] >= 4:

            ans = max(ans,cc[0]**2)





        if cc[1] >= 2:

            lst.append(cc[0])

        # if len(lst) == 2:

        #     print(lst[0] * lst[1])

        #     return

    if len(lst) >= 2:

        lst.sort(reverse=True)

        ans = max(ans, lst[0] * lst[1])



    print(ans)

if __name__ == '__main__':

    main()

import collections


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    cnt = collections.Counter(a)
    set_a = set(a)
    a = []
    a = list(set_a)
    a.sort(reverse=True)
    select = 0
    ans = 1
    tmp = 0
    flg = 0
    for i, aa in enumerate(a):
        if cnt[aa] >= 4 and flg == 0:
            tmp = aa * aa
            flg = 1
        if cnt[aa] >= 2:
            select += 1
            ans *= aa
        if select == 2:
            ans = max(tmp, ans)
            print(ans)
            return
    print((0))


if __name__ == "__main__":
    main()

import collections


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    # a.sort(reverse=True)
    c = collections.Counter(a)
    cl = c.most_common()
    # cl.sort(reverse = True)
    cnt = 1
    lst = []
    now = a[0]
    ans = 0
    for i, cc in enumerate(cl):
        if cc[1] >= 4:
            ans = max(ans, cc[0] ** 2)
        if cc[1] >= 2:
            lst.append(cc[0])
        # if len(lst) == 2:
        #     print(lst[0] * lst[1])
        #     return
    if len(lst) >= 2:
        lst.sort(reverse=True)
        ans = max(ans, lst[0] * lst[1])
    print(ans)


if __name__ == "__main__":
    main()

-    cnt = collections.Counter(a) -    set_a = set(a) -    a = [] -    a = list(set_a) -    a.sort(reverse=True) -    select = 0 -    ans = 1 -    tmp = 0 -    flg = 0 -    for i, aa in enumerate(a): -        if cnt[aa] >= 4 and flg == 0: -            tmp = aa * aa -            flg = 1 -        if cnt[aa] >= 2: -            select += 1 -            ans *= aa -        if select == 2: -            ans = max(tmp, ans) -            print(ans) -            return -    print((0)) +    # a.sort(reverse=True) +    c = collections.Counter(a) +    cl = c.most_common() +    # cl.sort(reverse = True) +    cnt = 1 +    lst = [] +    now = a[0] +    ans = 0 +    for i, cc in enumerate(cl): +        if cc[1] >= 4: +            ans = max(ans, cc[0] ** 2) +        if cc[1] >= 2: +            lst.append(cc[0]) +        # if len(lst) == 2: +        #     print(lst[0] * lst[1]) +        #     return +    if len(lst) >= 2: +        lst.sort(reverse=True) +        ans = max(ans, lst[0] * lst[1]) +    print(ans)