# ARC081C - Make a Rectangle

from collections import Counter





def main():

    n = int(eval(input()))

    lst = list(map(int, input().rstrip().split()))

    cnt = sorted(Counter(lst).most_common(), reverse=True)

    ans = []

    for i, j in cnt:

        if len(ans) >= 2:

            break

        if j >= 4:

            ans += [i] + [i]

        elif j >= 2:

            ans += [i]

    print((0 if ans == [] else ans[0] * ans[1]))





if __name__ == "__main__":

    main()
# ARC081C - Make a Rectangle (ABC071C)

from collections import Counter





def main():

    n = int(eval(input()))

    lst = list(map(int, input().rstrip().split()))

    cnt = sorted(

        list({k: v for k, v in list(Counter(lst).items()) if v >= 2}.items()), reverse=True

    )

    if cnt == []:

        print((0))

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

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

    else:

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





if __name__ == "__main__":

    main()
# ARC081C - Make a Rectangle
from collections import Counter


def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    cnt = sorted(Counter(lst).most_common(), reverse=True)
    ans = []
    for i, j in cnt:
        if len(ans) >= 2:
            break
        if j >= 4:
            ans += [i] + [i]
        elif j >= 2:
            ans += [i]
    print((0 if ans == [] else ans[0] * ans[1]))


if __name__ == "__main__":
    main()

# ARC081C - Make a Rectangle (ABC071C)
from collections import Counter


def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    cnt = sorted(
        list({k: v for k, v in list(Counter(lst).items()) if v >= 2}.items()),
        reverse=True,
    )
    if cnt == []:
        print((0))
    elif cnt[0][1] >= 4:
        print((cnt[0][0] ** 2))
    else:
        print((cnt[0][0] * cnt[1][0]))


if __name__ == "__main__":
    main()

-# ARC081C - Make a Rectangle +# ARC081C - Make a Rectangle (ABC071C) -    cnt = sorted(Counter(lst).most_common(), reverse=True) -    ans = [] -    for i, j in cnt: -        if len(ans) >= 2: -            break -        if j >= 4: -            ans += [i] + [i] -        elif j >= 2: -            ans += [i] -    print((0 if ans == [] else ans[0] * ans[1])) +    cnt = sorted( +        list({k: v for k, v in list(Counter(lst).items()) if v >= 2}.items()), +        reverse=True, +    ) +    if cnt == []: +        print((0)) +    elif cnt[0][1] >= 4: +        print((cnt[0][0] ** 2)) +    else: +        print((cnt[0][0] * cnt[1][0]))