We have N sticks with negligible thickness.
The length of the i-th stick is A_i.
Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the rectangle.

-----Constraints-----
 - 4 \leq N \leq 10^5
 - 1 \leq A_i \leq 10^9
 - A_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N

-----Output-----
Print the maximum possible area of the rectangle.
If no rectangle can be formed, print 0.

-----Sample Input-----
6
3 1 2 4 2 1

-----Sample Output-----
2

1 \times 2 rectangle can be formed.
[{"code": "n=int(input())\na=[int(i) for i in input().split()]\n\n\na.sort()\n\ncount=0\n\n\ndef get_num(a):\n    count=1\n    taishou = a.pop()\n    while a!=[]:\n        second=a.pop()\n        if taishou==second:\n            count+=1\n        else:\n            a.append(second)\n            break\n    if count==1:\n        return taishou,0\n    elif count==2 or count==3:\n        return taishou,1\n    else:\n        return taishou,2\n\none=0\ntwo=0\n\n\nwhile a!=[] and (one==0 or two==0):\n    hen,length=get_num(a)\n    if length==1:\n        if one==0:\n            one=hen\n        else:\n            two=hen\n    elif length==2:\n        if one==0:\n            one=hen\n            two=hen\n        else:\n            two=hen\n\nprint((one*two))\n\n", "passed": true, "time": 0.23, "memory": 14360.0, "status": "done"}, {"code": "N = int(input())\ndata = list(map(int, input().split()))\ndata.sort()\nans = []\nN -= 1\nwhile N > 0:\n    if data[N] == data[N - 1]:\n        ans.append(data[N])\n        N -= 1\n    N -= 1\n    if len(ans) >= 2:\n        break\n\nif len(ans) < 2:\n    print((0))\nelse:\n    print((ans[0] * ans[1]))\n\n", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a)\nlis = []\n \nfor i,j in a.items():\n    lis += [i]*(j//2)\n \n#print(lis)\n \nlis.sort(reverse=True)\nif len(lis) <= 1:\n    ans = 0\nelse:\n    ans = lis[0]*lis[1]\n \nprint(ans)", "passed": true, "time": 0.16, "memory": 14152.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\na = Counter(map(int, input().split()))\nxy = []\na = sorted(a.items(), key=lambda x: x[0], reverse=True)\nfor i in a:\n    if len(xy) == 2:\n        break\n    if i[1] >= 4:\n        xy.append(i[0])\n        xy.append(i[0])\n        break\n    if i[1] >= 2:\n        xy.append(i[0])\n\n    else:\n        pass\nprint(xy[0] * xy[1]) if len(xy) >= 2 else print(0)", "passed": true, "time": 0.23, "memory": 14340.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n    b.extend([k] * (v // 2))\nelse:\n    if 2 <= len(b):\n        b.sort()\n        print(b[-1] * b[-2])\n    else:\n        print(0)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n    for _ in range(v // 2):\n        b.append(k)\nelse:\n    if 2 <= len(b):\n        b.sort()\n        print(b[-1] * b[-2])\n    else:\n        print(0)", "passed": true, "time": 0.22, "memory": 14080.0, "status": "done"}, {"code": "from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\ncan_make=[i[0] for i in c.items() if i[1]>=2]\ncan_make_square=[i[0] for i in c.items() if i[1]>=4]\ncan_make+=can_make_square\ncan_make.sort()\n\nif len(can_make)<2:\n    print(0)\nelse:\n    print(can_make[-1]*can_make[-2])", "passed": true, "time": 0.21, "memory": 14284.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nd = {0:4}\nfor a in A:\n    d[a] = d.get(a, 0)+1\nlongest = 0\nfor i in d:\n    if d[i]>=2:\n        longest = max(longest, i)\nd[longest]-=2\n\nlongest_2nd = 0\nfor i in d:\n    if d[i]>=2:\n        longest_2nd = max(longest_2nd, i)\nprint(longest*longest_2nd)", "passed": true, "time": 0.14, "memory": 14372.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0, 0]\nfor k, v in a.items():\n    b.extend([k] * (v // 2))\nelse:\n    b.sort()\n    print(b[-1] * b[-2])", "passed": true, "time": 0.28, "memory": 14100.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ndic = {}\nfor i in range(n):\n    dic.setdefault(a[i],0)\n    dic[a[i]] += 1\nans = []\nfor item in list(dic.items()):\n    if item[1]>=2:\n        ans.append(item[0])\nif len(ans)<=1:\n    print((0))\nelse:\n    ans.sort()\n    if dic[ans[-1]]>=4:\n        print((ans[-1]**2))\n    else:\n        print((ans[-1]*ans[-2]))\n", "passed": true, "time": 0.15, "memory": 14108.0, "status": "done"}, {"code": "N = int(input())\nA = sorted(list(map(int,input().split())))[::-1]\n\nfor n in range(N-1):\n  if A[n]==A[n+1]:\n    A[n+1]=0\n  else:\n    A[n]=0\n\nA = sorted(A)[::-1]\nprint(A[0]*A[1])", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nbox,box2,ans = [],[],0\nacnt = dict(Counter(a))\nacnt = sorted(acnt.items(), key=lambda x:x[0],reverse=True)\na_val = [acnt[x][1] for x in range(len(acnt))]\na_key = [acnt[y][0] for y in range(len(acnt))]\nfor i in range(len(a_val)):\n\tif a_val[i] >= 4:\n\t\tbox2.append(a_key[i]**2)\n\tif 2 <= a_val[i]:\n\t\tbox.append(a_key[i])\nbox.sort(reverse=True)\nif len(box2) >= 2:\t\n\tans = max(box2)\nif len(box) >= 2:\n    print(max(ans,(box[0]*box[1])))\n    return\nprint(0)", "passed": true, "time": 0.16, "memory": 14248.0, "status": "done"}, {"code": "import collections\nn=int(input())\na=list(map(int,input().split()))\nc = collections.Counter(a)\nb=[0,0]\nd=[0,0]\nfor i in c:\n    if c[i]>=4:\n        b.append(i)\n    elif c[i]>=2:\n        d.append(i)\nb.sort(reverse=True)\nd.sort(reverse=True)\nif b[0]>d[0]:\n    print((b[0]*b[0]))\nelif b[0]<d[1]:\n    print((d[0]*d[1]))\nelse:\n    print((b[0]*d[0]))\n", "passed": true, "time": 0.2, "memory": 14072.0, "status": "done"}, {"code": "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = {}\na = []\nfor i in A:\n    if i in d:\n        d[i] += 1\n        if d[i] == 2:\n            a.append(i)\n            d[i] = 0\n    else:\n        d[i] = 1\n\na.sort()\nif len(a) < 2:\n    print(0)\nelse:\n    print(a[-1]*a[-2])", "passed": true, "time": 0.15, "memory": 14312.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C(map(int, input().split()))\n\nb = []\nfor k, v in a.items():\n    b.extend([k] * (v // 2))\nelse:\n    if 2 <= len(b):\n        b.sort()\n        print(b[-1] * b[-2])\n    else:\n        print(0)", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\ncounter = dict(Counter(A))\nfour = []\ntow = []\nfor key in counter.keys():\n    if counter[key] >= 4:\n        four.append(key)\n        tow.append(key)\n    elif counter[key]>=2:\n        tow.append(key)\n\nif len(four) == 0 and len(tow) <= 1:\n    print(0)\nelse:\n    ans = 0\n    four.sort(reverse=True)\n    tow.sort(reverse=True)\n    if len(four) >= 1:\n        ans = max(ans, four[0]**2)\n    if len(tow) >= 2:\n        ans = max(ans, tow[1] * tow[0])\n    print(ans)", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n    if j >= 4:\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\nif len(ans) >= 2:\n    print(ans[0] * ans[1])\nelse:\n    print(0)", "passed": true, "time": 0.2, "memory": 14292.0, "status": "done"}, {"code": "import collections\nN=int(input())\nL=list(map(int,input().split()))\nc = collections.Counter(L)\nA=list(c.keys())\nB=list(c.values())\nR=list()\nfor i in range(len(A)):\n  if B[i]>=2:\n    R.append([A[i],B[i]])\nR=sorted(R,reverse=True)\nif len(R)==0:\n  print(0)\n  return\nif R[0][1]>=4:\n  print(R[0][0]**2)\nelif len(R)<2:\n  print(0)\nelse:\n  print(R[0][0]*R[1][0])", "passed": true, "time": 0.19, "memory": 14296.0, "status": "done"}, {"code": "N=int(input())\nA=sorted(list(map(int,input().split())))\nl=[]\ns=set()\nfor i in range(N):\n    if A[N-i-1] in s:\n        l.append(A[N-i-1])\n        s.discard(A[N-i-1])\n    else:\n        s.add(A[N-i-1])\nl.sort()\nprint(0 if len(l)<2 else l[-1]*l[-2])", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "from collections import Counter\nn=int(input())\nc=Counter(list(map(int, input().split())))\nl=list()\nfor k,v in c.items():\n    for _ in range(v//2):\n        l.append(k)\n\nl.sort()\nl.reverse()\nif len(l)>=2:\n    print(l[0]*l[1])\nelse:\n    print(0)", "passed": true, "time": 0.19, "memory": 14332.0, "status": "done"}, {"code": "n = int(input())\na=list(map(int,input().split()))\n\na.sort(reverse = True)\nans = 0\nb = a.copy()\nb = list(set(b))\nb.sort(reverse = True)\nc = [0]*len(b)\nj = 0\nc[j] = 1\nfor i in range(1,n):\n    if a[i-1] == a[i]:\n        c[j] +=1\n    else:\n        j+=1\n        c[j] +=1\nfor i in range(len(b)):\n    if c[i] >= 4:    \n        \n        ans = b[i]*b[i]\n        break\n    elif c[i] >= 2:\n        for j in range(i+1,len(b)):\n            if c[j] >= 2:\n                ans = b[i]*b[j]\n                break\n        break\nprint(ans)", "passed": true, "time": 0.18, "memory": 14356.0, "status": "done"}, {"code": "n = int(input())\nA = tuple(map(int, input().split()))\nA = sorted(A, reverse=True)\nfrom collections import Counter\nCA = Counter(A)\n\nb = 0\nfor a in A:\n    if CA[a] >= 2:\n        CA[a] -= 2\n        b = a\n        break\n\nc = 0\nfor a in A:\n    if CA[a] >=2:\n        c = a\n        break\nprint((b*c))\n", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0] * 2\nfor k, v in a.items():\n    if 4 <= v:\n        b.append(k)\n    if 2 <= v:\n        b.append(k)\nelse:\n    b.sort()\n    print(b[-1] * b[-2])", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "import collections\nN = int(input())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nlsline = []\nfor i in counterA.keys():\n    if counterA[i] >= 2:\n        lsline.append(i)\nlsline.sort(reverse=True)\nif bool(lsline):\n    if counterA[lsline[0]] >= 4:\n        ans = lsline[0]*lsline[0]\n    elif len(lsline) < 2:\n        ans = 0\n    else:\n        ans = lsline[0]*lsline[1]\nelse:\n    ans = 0\nprint(ans)", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\ncount = {}\nrect = {}\nfor i in range(N):\n    if A[i] in rect:\n        rect[A[i]] += 1\n    elif A[i] in count:\n        rect[A[i]] = 2\n    else:\n        count[A[i]] = 1\n\nif len(rect) < 1:\n    ans = 0\nelse:\n    x = max(rect)\n    if rect[x] >= 4:\n        ans = x * x \n    else:\n        del rect[x]\n        if len(rect) < 1:\n            ans = 0\n        else:\n            y = max(rect)\n            ans = x * y\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "N=int(input())\nA=list(map(int,input().strip().split()))\n\nd={}\n\nfor n in range(N):\n    if d.get(A[n])==None:\n        d[A[n]]=1\n    else:\n        d[A[n]]+=1\n\nd=sorted(list(d.items()),reverse=True)\n\ncnt=0\nans=0\nfor i in range(len(d)):\n    if cnt==0:\n        if d[i][1]>=4:\n            ans=d[i][0]**2\n            break\n        elif d[i][1]>=2:\n            temp=d[i][0]\n            cnt+=1\n    else:\n        if d[i][1]>=2:\n            ans=temp*d[i][0]\n            break\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14352.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\na.sort()\nl = []\nwhile a:\n  x = a.pop()\n  if not a:\n    break\n  if a[-1] == x:\n    a.pop()\n    l.append(x)\n  if len(l) == 2:\n    break\nif len(l) != 2:\n  print(0)\nelse:\n  print(l[0] * l[1])", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\n\nstore = 0\nbig = 0\n\nfor i in range (0, N-1):\n\tif store == 1:\n\t\tstore = 0\n\telse:\n\t\tif A[i] == A[i+1] and big == 0:\n\t\t\tbig = A[i]\n\t\t\tstore = 1\n\t\telif A[i] == A[i+1]:\n\t\t\tprint(A[i]*big)\n\t\t\treturn\n            \nprint(0)", "passed": true, "time": 0.15, "memory": 14244.0, "status": "done"}, {"code": "from collections import Counter\n\nN=int(input())\nA=list(map(int,input().split()))\n\nc = Counter(A)\nmc=[]\nfor k in c.keys():\n  if c[k]>=2:mc.append(k)\n    \nif len(mc)==0:\n  print(0)\n  return\n\nelif len(mc)==1:\n  if c[mc[0]]<4:\n    print(0)\n    return\n  else:\n    print(mc[0]**2)\n    return\n  \nmc = sorted(mc,reverse=True)\nif c[mc[0]] < 4:print(mc[0]*mc[1])\nelse:print(mc[0]**2)", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\nans = [0, 0]\nj = 0\nnow = -1\ncount = 1\nfor i in range(N):\n  if A[i] == now:\n    count += 1\n    if count == 2:\n      ans[j] = now\n      if j == 1:\n        print(ans[0] * ans[1])\n        return\n      j += 1\n    if count == 4:\n      print(now * now)\n      return\n      \n  else:\n    now = A[i]\n    count = 1\n\nprint(0)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "import sys\n\nn,*a=list(map(int,sys.stdin.read().split()))\n\na.sort(reverse=True)\nc=0\nf=0\nans=[]\nfor i in range(n-1):\n  if a[i]==a[i+1]:\n    c+=1\n    f+=1\n    ans.append(a[i])\n  else:\n    f=0\n  if (c>1 and f==1) or (c>2 and f==3):\n    print((ans[0]*ans[-1]))\n    return\nprint((0))\n  \n  \n", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "#\n# abc071 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"6\n3 1 2 4 2 1\"\"\"\n        output = \"\"\"2\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"4\n1 2 3 4\"\"\"\n        output = \"\"\"0\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_3(self):\n        input = \"\"\"10\n3 3 3 3 4 4 4 5 5 5\"\"\"\n        output = \"\"\"20\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N = int(input())\n    A = list(map(int, input().split()))\n\n    A.sort(reverse=True)\n    l1 = l2 = 0\n    for i in range(1, N):\n        if l1 == 0:\n            if A[i] == A[i-1]:\n                l1 = A[i-1]\n        else:\n            if i < N-1 and A[i+1] == A[i]:\n                l2 = A[i]\n                break\n\n    print((l1*l2))\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14492.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\n\nb = []\nfor k, v in C([int(x) for x in input().split()]).items():\n    b.extend([k] * (v // 2))\nelse:\n    if 2 <= len(b):\n        b.sort()\n        print(b[-1] * b[-2])\n    else:\n        print(0)", "passed": true, "time": 0.15, "memory": 14208.0, "status": "done"}, {"code": "def main():\n    _ = int(input())\n    a = [int(an) for an in input().split()]\n    a.sort(reverse=True)\n    line = -1\n    lines = []\n    for an in a:\n        if line == an:\n            lines.append(an)\n            if len(lines) == 2:\n                break\n            line = -1\n        else:\n            line = an\n    print((lines[0] * lines[1] if len(lines) == 2 else 0))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14192.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n    if a[i] not in num_map:\n        num_map[a[i]] = 1\n    else:\n        num_map[a[i]] += 1\n\nkeys = sorted(list(num_map.keys()), reverse=True)\n\ntwo_over = []\ncounter = 0\nres = 1\nfor i in keys:\n    if num_map[i] >= 4:\n        res *= i ** (2 - counter)\n        counter += 2\n    elif num_map[i] >= 2:\n        counter += 1\n        res *= i\n    if counter >= 2:\n        print(res)\n        break\nelse:\n    print((0))\n", "passed": true, "time": 0.23, "memory": 14240.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nd={}\nsei=[]\ntyo=[]\nfor s in a:\n  if s not in d:\n    d[s]=0\n  d[s]+=1\n  \nfor t in a:\n  if d[t]>=2:\n    tyo.append(t)\n  if d[t]>=4:\n    sei.append(t)\n  d[t]=0\n  \nif len(sei)==0 and len(tyo)<=1:\n  print(0)\n  \nelse:\n  tyos=0\n  seis=0\n  if len(tyo)>1:\n    tyo=sorted(tyo)\n    tyos+=tyo[-1]*tyo[-2]\n  if len(sei)>0:\n    sei=sorted(sei)\n    seis+=sei[-1]**2\n    \n  print(max(tyos,seis))", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "input()\nd = {}\nfor i in map(int, input().split()):\n    if i in d:\n        d[i] += 1\n    else:\n        d[i] = 1\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n    if len(ans) < 2 and j >= 4:\n        ans.append(i)\n        d[i] -= 2\n    if len(ans) < 2 and j >= 2:\n        ans.append(i)\n        d[i] -= 2\n    if len(ans) == 2:\n        print(ans[0] * ans[1])\n        break\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "input();a=list(map(int,input().split()));d={}\nfor i in a:\n  if i in d:\n    d[i] += 1\n  else:\n    d[i] = 1\nd={i:j for i,j in d.items() if j>1}\nif len(d)<2:\n  print(0)\nelse:\n  d=sorted(d.items(),key=lambda x:(-x[0],-x[1]))\n  print(d[0][0]*d[1][0] if d[0][1]<4 else d[0][0]*d[0][0])", "passed": true, "time": 0.32, "memory": 14136.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a)\nlis = []\n\nfor i,j in a.items():\n    lis += [i]*(j//2)\n\n#print(lis)\n\nlis.sort(reverse=True)\nif len(lis) <= 1:\n    ans = 0\nelse:\n    ans = lis[0]*lis[1]\n\nprint(ans)", "passed": true, "time": 0.16, "memory": 14288.0, "status": "done"}, {"code": "from collections import deque\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort(reverse=True)\nq = deque()\nfor i in range(N):\n    q.append(A[i])\n\ns = []\nw = True\nwhile q:\n    if len(q) == 1:\n        break\n    else:\n        i = q.popleft()\n        j = q.popleft()\n        if i == j:\n            s.append(i)\n        else:\n            q.appendleft(j)\n        if len(s) == 2:\n            print((s[0] * s[1]))\n            w = False\n            break\nif w:\n    print((0))\n", "passed": true, "time": 0.25, "memory": 14268.0, "status": "done"}, {"code": "from collections import Counter\ndef main():\n    n = int(input())\n    A = list(map(int, input().split()))\n    c = Counter(A)\n    B = sorted([(k, v) for k, v in list(c.items()) if v >= 2], reverse = True, key = lambda x: x[0])\n    if len(B) < 2:\n        print((0))\n    elif B[0][1] >= 4:\n        print((B[0][0] ** 2))\n    else:\n        print((B[0][0] * B[1][0]))\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.19, "memory": 14232.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\n\nd = {}\nfor i in a:\n    if i in d:\n        d[i] += 1\n    else:\n        d[i] = 1\nd = sorted(d.items(), key=lambda x:x[0], reverse=True)\n\nm = len(d)\nans = 0\nflg = True\nfor i in range(m):\n    k, v = d[i][0], d[i][1]\n    if ans == 0:\n        if v >= 4:\n            ans = k**2\n            flg = True\n            break\n        elif v >= 2:\n            ans = k\n    elif v >= 2:\n        ans *= k\n        flg = True\n        break\nprint(ans) if flg else print(0)\n        ", "passed": true, "time": 0.2, "memory": 14396.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\nc = {}\nd = [0,0]\nans = 0\n\nfor i in a:\n    if i not in c:\n        c[i]=0\n    c[i]+=1\n\nfor i,v in zip(c.keys(),c.values()):\n    if v >= 4:\n        d.append(i)\n        d.append(i)\n    elif v >= 2:\n        d.append(i)\n        \nd.sort(reverse = True)\n\nif len(d) <= 3:\n    ans = max(ans,0)\nelse:\n    ans = max(ans,d[0]*d[1])\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    a_lst = list(map(int, input().split()))\n    lst = [0, 0]\n\n    a_lst.sort()\n    a_lst.reverse()\n\n    length = a_lst[0]\n    count = 0\n    for i in range(n):\n        if a_lst[i] == length:\n            count += 1\n\n            if count == 2:\n                lst.append(a_lst[i])\n                count = 0\n\n            if len(lst) == 4:\n                break\n\n        else:\n            count = 1\n            length = a_lst[i]\n\n    area = lst[-1] * lst[-2]\n    print(area)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "from collections import Counter\n \ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n    if j >= 4:\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\nif len(ans) >= 2:\n    print(ans[0] * ans[1])\nelse:\n    print(0)", "passed": true, "time": 0.24, "memory": 14156.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\ndic = {}\nfor a in A:\n  if a in dic:\n    dic[a] += 1\n  else:\n    dic[a] = 1\n    \ndic = sorted(dic.items(), reverse=True)\n\nans = 1\ncheck = 0\nbool1 = False\nfor (i,j) in dic:\n  cnt = j // 2\n  for _ in range(cnt):\n    ans *= i\n    check += 1\n    if check == 2:\n      bool1 = True\n      break\n  if bool1:\n    break\n\nprint(ans if ans != 1 else 0)", "passed": true, "time": 0.21, "memory": 14212.0, "status": "done"}, {"code": "N = int(input())\nA = [int(x) for x in input().split()]\nA.sort(reverse = True)\n\ns = []\ni = 0\nwhile i < N - 1:\n    if len(s) == 2:\n        break\n    if A[i] == A[i + 1]:\n        s.append(A[i])\n        i += 2\n    else:\n        i += 1\n\nif len(s) == 2:\n    print(s[0] * s[1])\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\ni = 0\nc = 0\nx = 0\ny = 0 \nwhile i < len(a) - 1:\n\tif a[i] == a[i+1] and c == 0:\n\t\tx = a[i]\n\t\ti += 2\n\t\tc += 1\n\t\tcontinue\n\tif a[i] == a[i+1] and c == 1:\n\t\ty = a[i]\n\t\tbreak\n\ti += 1\nif x != 0 and y != 0:\n\tprint(x*y)\nelse:\n\tprint(0)", "passed": true, "time": 0.15, "memory": 14112.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nimport collections\nb = collections.Counter(a).most_common()\nli4 = []\nli2 = []\nansli = []\nfor k in b:\n    if k[1]>=4:\n        li4 +=[k[0]]\n        ansli += [k[0]**2]\n    if k[1]>=2:\n        li2 +=[k[0]]\n\nif len(li2)>=2:\n    li22 = sorted(li2)\n    ansli += [li22[-1]*li22[-2]]\nif ansli:\n    print(max(ansli))\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n = int(input())\n#a, b = map(int,input().split())\nal = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\ndic = {}\nfor ai in al:\n    dic[ai] = dic.get(ai, 0)+1\n\nedges = sorted(list(dic.items()), reverse=True)\nans = 0\npartial = False\ntemp = 0\nfor tup in edges:\n    e, num = tup\n    if num == 1:\n        continue\n    elif num == 2 or num == 3:\n        if partial:\n            ans = temp*e\n            break\n        else:\n            partial = True\n            temp = e\n    else:\n        if partial:\n            ans = temp*e\n            break\n        else:\n            ans = e**2\n            break\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nd = {}\nfor i in a:\n  if i in d: d[i] += 1\n  else: d[i] = 1\n\nt = 0\nans = []\nfor k,v in sorted(d.items(), key=lambda x: x[0], reverse=True):\n  if v >= 4 and t == 0:\n    print(k*k)\n    return\n  elif v >= 2:\n    ans.append(k)\n    t += 1\n  if t == 2:\n    print(ans[0]*ans[1])\n    return\nprint(0)", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nrods = []\ntmp = {}\nfor i in a:\n    if i in tmp:\n        tmp[i] += 1\n        if tmp[i] >= 2:\n            rods.append(i)\n            tmp[i] = 0\n    else:\n        tmp[i] = 1\n\nrods.sort(reverse=True)\nif len(rods) >= 2:\n    print(rods[0] * rods[1])\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nA.sort()\nl = 0\nh = 0\ni = n-1\nwhile i >= 0:\n    if i > 0 and A[i] == A[i-1] and l == 0:\n        l = A[i]\n        i -= 2\n    elif i > 0 and A[i] == A[i-1] and h == 0:\n        h = A[i]\n        break\n    else:\n        i-=1\nprint (l*h)", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\nA.sort(reverse=True)\n\nfor i in A:\n  D[i] += 1\n\nL = []\n\nfor i, x in D.items():\n  if x >= 4:\n    L.append(i)\n    L.append(i)\n    break\n  elif x >= 2:\n    L.append(i)\n\nif len(L) <= 1:\n  print(0)\nelse:\n  print(L[0]*L[1])", "passed": true, "time": 0.23, "memory": 14320.0, "status": "done"}, {"code": "N = int(input())\nA = [int(a) for a in input().split(\" \")]\n\nA.sort(reverse=True)\nl1 = 0\nc1 = 0\nl2 = 0\nc2 = 0\n\nL1 = 0\nL2 = 0\n\nfor i in range(len(A)):\n  if L1 and L2:\n    break\n  elif L1:\n    if l2 == A[i]:\n      c2 += 1\n    elif l2 != A[i]:\n      l2 = A[i]\n      c2 = 1\n    if c2 == 2:\n      L2 = l2\n  else:\n    if l1 == A[i]:\n      c1 += 1\n    elif l1 != A[i]:\n      l1 = A[i]\n      c1 = 1\n    if c1 == 2:\n      L1 = l1\n\nprint(L1 * L2)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "import collections\n\n_=input()\na=list(map(int,input().split()))\nc=collections.Counter(a)\nl=sorted(c.items(), key=lambda x: x[0])\nx=0\nfor i in l[::-1]:\n    if i[1]>3:\n        if x:\n            print(i[0]*x)\n            return\n        else:\n            print(i[0]*i[0])\n            return\n    elif i[1]>1:\n        if x:\n            print(i[0]*x)\n            return\n        else:\n            x=i[0]\nprint(0)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\n\nfor i in A:\n  D[i] += 1\n\nL1 = [0, 0]\nL2 = [0]\n\nfor i, x in D.items():\n  if x >= 4:\n    L2.append(i)\n  if x >= 2:\n    L1.append(i)\n\nL1.sort(reverse=True)\nL2.sort(reverse=True)\n\nprint(max(L1[0]*L1[1], L2[0]**2))", "passed": true, "time": 0.14, "memory": 14360.0, "status": "done"}, {"code": "from collections import defaultdict\n\nd = defaultdict(int)\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = []\nfor i in a:\n  d[i] += 1\n  if d[i] == 2:\n    d[i] = 0\n    ans.append(i)\nans.sort(reverse=True)\nif len(ans) >= 2:\n  print((ans[0]*ans[1]))\nelse:\n  print((0))\n", "passed": true, "time": 0.15, "memory": 14188.0, "status": "done"}, {"code": "from collections import Counter\nN = int(input())\nA = Counter(list(map(int, input().split())))\nB = dict(sorted(list(A.items()), reverse=True))\nans = []\nfor i, j in list(B.items()):\n    if j >= 4:\n        ans.append(i)\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\nif len(ans) >= 2:\n    print((ans[0] * ans[1]))\nelse:\n    print((0))\n", "passed": true, "time": 0.19, "memory": 14076.0, "status": "done"}, {"code": "import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nA = collections.Counter(A).most_common()\nN = len(A)\n\nans = [0]\n\nfor i in range(N):\n    if A[i][1] >= 4:\n        ans.append(A[i][0]**2)\n\nref = []\nfor j in range(N):\n    if A[j][1] >= 2:\n        ref.append(A[j][0])\nref = sorted(ref)\nif len(ref) >= 2:\n    ans.append(ref[-2]*ref[-1])\n\nprint((max(ans)))\n", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "n = int(input())\na1 = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a1).most_common()\nl = []\nfor i in range(len(a)):\n    if 2 <= a[i][1]:\n        for h in range(a[i][1]//2):\n            l.append(a[i][0])\nl.sort()\nif 2 <= len(l):\n    print(l[-1]*l[-2])\nelse:\n    print(0)", "passed": true, "time": 0.24, "memory": 14108.0, "status": "done"}, {"code": "N=int(input())\nA=list(map(int,input().split()))\nA.sort()\n\ni=N-1\nans=1\ncount=0\nwhile i>=1:\n    if A[i-1]==A[i]:\n        ans*=A[i]\n        i-=2\n        count+=1\n    else:\n        i-=1\n    if count==2:\n        print(ans)\n        break\nelse:\n    print((0))\n", "passed": true, "time": 0.15, "memory": 14332.0, "status": "done"}, {"code": "import collections\n\nN = int(input())\na = [int(i) for i in input().split()]\ncheck = []\ndict = collections.Counter(a)\nfor a, b in dict.items():\n    if b >= 2:\n        check.append(a)\n\nif len(check) >=2:\n    check.sort()\n    if dict[check[-1]] >= 4:\n        print(check[-1] ** 2)\n    else:\n        print(check[-1] * check[-2])\nelif len(check) == 1:\n    if dict[check[-1]] >= 4:\n        print(check[-1] ** 2)\n    else:\n        print(0)\nelse:\n    print(0)", "passed": true, "time": 0.15, "memory": 14360.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nimport collections\na = collections.Counter(A)\nb = []\nfor i, j in a.items():\n    if j >= 2:\n        b.append([i,j])\nb.sort(reverse=True)\nif len(b) >= 1 and b[0][1] >= 4:\n    print(b[0][0] ** 2)\nelif len(b) >= 2:\n    print(b[0][0] * b[1][0])\nelse:\n    print(0)", "passed": true, "time": 0.15, "memory": 14324.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n    if 4 <= v:\n        b.append(k)\n    if 2 <= v:\n        b.append(k)\nelse:\n    if len(b) <= 1:\n        print(0)\n    else:\n        b.sort()\n        print(b[-1] * b[-2])", "passed": true, "time": 0.15, "memory": 14228.0, "status": "done"}, {"code": "from collections import deque\nn = int(input())\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n    if a[i] not in num_map:\n        num_map[a[i]] = 1\n    else:\n        num_map[a[i]] += 1\n\nkeys = sorted(list(num_map.keys()), reverse=True)\n\nq = deque()\nfor i in keys:\n    if num_map[i] >= 2:\n        q.append([i, num_map[i]])\nres = 1\ncounter = 0\nwhile len(q) != 0:\n    key, value = q.popleft()\n    res *= key\n    if value - 2 >= 2:\n        q.appendleft([key, value - 2])\n    counter += 1\n    if counter == 2:\n        print(res)\n        break\nelse:\n    print((0))\n", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "from collections import defaultdict\nLineger_Dict = defaultdict(int)\nN = int(input())\nN_List = list(map(int,input().split()))\nfor i in N_List:\n    Lineger_Dict[i] += 1\n\n    \nRec = sorted([k for k,v in Lineger_Dict.items() if v >= 2] + [k for k,v in Lineger_Dict.items() if v >= 4])\nif len(Rec) < 2:\n    print(0)\nelse:\n    print(Rec[-1]*Rec[-2])", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n    N, *A = list(map(int, read().split()))\n\n    ans = 0\n    counter = Counter(A)\n    vec1 = [k for k, v in list(counter.items()) if v >= 2]\n    vec2 = [k for k, v in list(counter.items()) if v >= 4]\n\n    vec1.sort()\n    if len(vec1) >= 2:\n        ans = vec1[-2] * vec1[-1]\n\n    vec2.sort()\n    if len(vec2) >= 1:\n        ans = max(ans, vec2[-1] ** 2)\n\n    print(ans)\n    return\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "import collections\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nans = [i[0] for i in c.items() if i[1] >= 2]\nans.extend([i[0] for i in c.items() if i[1] >= 4])\nans.extend([0,0])\nans.sort(reverse=True)\nprint(ans[0]*ans[1])", "passed": true, "time": 0.15, "memory": 14280.0, "status": "done"}, {"code": "n = int(input())\na = sorted(list(map(int, input().split())))\ni = n - 1\np = 0\nq = 0\nwhile i > 0:\n  if a[i] == a[i-1]:\n    if p == 0:\n      p = a[i]\n      i -= 1\n    else:\n      q = a[i]\n      break\n  i -= 1\nprint(p*q)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\n\na.sort()\na.reverse()\n\nc = [0,0]\ni = 0\n\nwhile i < N-1:\n    if a[i] == a[i+1]:\n        c.append(a[i])\n        i+=2\n    else:\n        i+=1\n        \nc.sort()\nc.reverse()\nprint(c[0]*c[1])", "passed": true, "time": 0.23, "memory": 14088.0, "status": "done"}, {"code": "N = int(input())\nA = [int(x) for x in input().split()]\nA.sort(reverse = True)\n\ns = []\ni = 0\nwhile i < N - 1:\n    if A[i] == A[i + 1]:\n        s.append(A[i])\n        if len(s) == 2:\n            print(s[0] * s[1])\n            break\n        i += 2\n    else:\n        i += 1\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n    if len(ans) < 2 and j >= 4:\n        ans.append(i)\n        d[i] -= 2\n    if len(ans) < 2 and j >= 2:\n        ans.append(i)\n        d[i] -= 2\n    if len(ans) == 2:\n        print(ans[0] * ans[1])\n        break\nelse:\n    print(0)", "passed": true, "time": 0.18, "memory": 14236.0, "status": "done"}, {"code": "N=int(input())\nA=sorted(list(map(int,input().split())),reverse=True)\ndef sameA(List):\n  for i in range(len(List)):\n    try:\n      if List[i]==List[i+1]:\n        ans=List[i]\n        anslist=A[i+2:]\n        return ans,anslist\n    except IndexError:\n      return False,False\na1,list1=sameA(A)\nif not a1==False:\n  a2,list2=sameA(list1)\n  if not a2==False:\n    print(a1*a2)\n  else:\n    print(0)\nelse:\n  print(0)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate:  2020-09-04 15:20:21 +0900\n# LastModified: 2020-09-04 15:31:03 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom collections import Counter\n\n\ndef main():\n    _ = int(input())\n    a = list(map(int, input().split()))\n    a_cnt = [[key, val] for key, val in list(Counter(a).items()) if val >= 2]\n    if len(a_cnt) == 0:\n        print((0))\n        return\n    a_cnt.sort(key=lambda x: x[0], reverse=True)\n    if a_cnt[0][1] >= 4:\n        print((a_cnt[0][0]**2))\n    elif len(a_cnt) == 1:\n        print((0))\n    else:\n        print((a_cnt[0][0]*a_cnt[1][0]))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\nL = []\ncnt = 0\ni = 0\nwhile i <= N-2:\n    if A[i] == A[i+1]:\n        L.append(A[i])\n        i += 1\n        cnt += 1\n        if cnt == 2:\n            break\n    i += 1\nif len(L) == 2:\n    print(L[0]*L[1])\nelse:\n    print(0)", "passed": true, "time": 0.15, "memory": 14296.0, "status": "done"}, {"code": "n=int(input())\nl=list(map(int,input().split()))\nd={}\nfor a in l:\n    if a in d:\n        d[a]+=1\n    else:\n        d[a]=1\nks=sorted(d,reverse=True)\nf=0\nfor i,k in enumerate(ks):\n    if d[k]>=4:\n        print((k*k))\n        return\n    if d[k]>=2:\n        f=k\n        break\ns=0\nfor k in ks[i+1:]:\n    if d[k]>=2:\n        s=k\n        break\nprint((f*s))\n", "passed": true, "time": 0.15, "memory": 14224.0, "status": "done"}, {"code": "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0] * 2\nfor k, v in a.items():\n    b.extend([k] * (v // 2))\nelse:\n    b.sort()\n    print(b[-1] * b[-2])", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nans = []\nflg = 0\n\nA.sort(reverse=True)\n\nfor i in range(N-1):\n  if A[i] == A[i+1] and flg == 0:\n    ans.append(A[i])\n    flg = 1\n  else:\n    flg = 0\n\nif len(ans) > 1:\n  print(ans[0]*ans[1])\nelse:\n  print(0)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nnum = Counter(a)\n\nif n == len(num)+1 or n == len(num):\n    print((0))\n    return\n\nans = []\n\nfor i in num:\n    if num[i] >= 2:\n        ans.append(i)\n    if num[i] >= 4:\n        ans.append(i)     \nn = max(ans)\nans.pop(ans.index(max(ans)))\nm = max(ans)\nprint((n*m))\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = Counter(list(map(int, input().split())))\na = [list(x) for x in a.items() if x[1]>=2]\na.sort(reverse=True, key=lambda x: (x[0], x[1]))\ncount = 0\nbase = 4\nfor i in range(len(a)):\n    if count == 1:\n        print(l*a[i][0])\n        return\n    else:\n        l = a[i][0]\n        count += 1\n\n    if a[i][1]>=4:\n        print(a[i][0]*a[i][0])\n        return\n\nprint(0)", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n    if j >= 4:\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\n    if len(ans) >= 2:\n        print(ans[0] * ans[1])\n        break\nelse:\n    print(0)", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n    N, *A = list(map(int, read().split()))\n\n    A.sort(reverse=True)\n\n    i = 0\n    w = h = 0\n    while i < N - 1:\n        if A[i] == A[i + 1]:\n            if w == 0:\n                w = A[i]\n            else:\n                h = A[i]\n                break\n            i += 2\n        else:\n            i += 1\n\n    print((w * h))\n    return\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "import heapq\nfrom collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nl = []\nfor i in set(a):\n    if c[i] >= 2:\n        for j in range(c[i]//2):\n            l.append(i)\nif len(l) >= 2:\n    print(heapq.nlargest(2, l)[0]*heapq.nlargest(2, l)[1])\nelse:\n    print(0)", "passed": true, "time": 0.23, "memory": 14292.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\nans = [0, 0]\nfor i, j in list(Counter(list(map(int, input().split()))).items()):\n    if j >= 4:\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\nans.sort()\nprint((ans[-1] * ans[-2]))\n", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "import collections\nN = int(input())\nA = sorted(collections.Counter(int(T) for T in input().split()).most_common(),reverse=True)\nFlag = False\nLS = 0\nSS = 0\nfor T in range(0,len(A)):\n    if LS==0 and A[T][1]>=4:\n        Sq = A[T][0]**2\n        Flag = True\n        break\n    if A[T][1]>=2:\n        if LS==0:\n            LS = A[T][0]\n        else:\n            SS = A[T][0]\n            Sq = LS*SS\n            Flag = True\n            break\nif Flag:\n    print(Sq)\nelse:\n    print(0)", "passed": true, "time": 0.24, "memory": 14256.0, "status": "done"}, {"code": "from collections import defaultdict\nn=int(input())\na=list(map(int,input().split()))\ndd=defaultdict(lambda:0)\nfor aa in a:\n  dd[aa]+=1\nx,y=0,0\nfor k in sorted(dd.keys(), reverse=True):\n  if x==0 and dd[k]>=2:\n    x=k\n    dd[k]-=2\n  if y==0 and dd[k]>=2:\n    y=k\n    break\nprint(x*y)", "passed": true, "time": 0.14, "memory": 14184.0, "status": "done"}, {"code": "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\ndef main():\n    n = i_input()\n    a = i_list()\n\n    a.sort()\n\n    l = []\n    start = a[0]\n    cnt = 1\n    for i in a:\n        if i == start:\n            cnt += 1\n        else:\n            start = i\n            cnt = 1\n        if cnt == 2:\n            l.append(i)\n            cnt = 0\n    if cnt == 2:\n        l.append(i)\n    if len(l) < 2:\n        print((0))\n    else:\n        print((l[-1]*l[-2]))\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.24, "memory": 14420.0, "status": "done"}, {"code": "from collections import Counter\n\n\ndef solve():\n    c = Counter(arr)\n    four_edges = [k for k, v in list(c.items()) if v >= 4]\n    two_edges = [k for k, v in list(c.items()) if 1 < v < 4]\n    four_edges.append(0)\n    two_edges.append(0)\n    four_edges.sort(reverse=True)\n    two_edges.sort(reverse=True)\n\n    area_f = four_edges[0] * four_edges[0]\n    if len(two_edges) >= 2:\n        area_t = two_edges[0] * two_edges[1]\n    else:\n        area_t = 0\n    area_t_t = two_edges[0] * four_edges[0]\n    max_area = max(area_f, max(area_t, area_t_t))\n    return max_area\n\n\nN = int(input())\narr = list(map(int, input().split()))\nres = solve()\nprint(res)\n", "passed": true, "time": 0.22, "memory": 14292.0, "status": "done"}, {"code": "n=int(input())\nL=list(map(int,input().split()))\nL.sort(reverse=True)\n\n\nimport collections\nd=collections.Counter(L)\nM=0\nm=[0,0]\nfor v in d:\n\tif d[v]>=4:\n\t\tM=max(M,v)\n\telif d[v]>=2:\n\t\tm.append(v)\nm.sort(reverse=True)\n\nprint(max(M**2,m[0]*m[1],M*m[0]))", "passed": true, "time": 0.14, "memory": 14040.0, "status": "done"}, {"code": "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse=True)\n\ncnt = 0\nfor i in range(N-1):\n  if A[i] - A[i+1] == 0:\n    cnt +=1\nif cnt < 2:\n  print(\"0\")\n  return\n\nleng1 = 0\nleng2 = 0\ndiff = 10**9\n\ni = 0\nwhile diff != 0:\n  diff = A[i] - A[i+1]\n  i += 1  \nleng1= A[i]\n\nA.remove(leng1)\nA.remove(leng1)\n\ni = 0\ndiff = 10**9\nwhile diff != 0:\n  diff = A[i] - A[i+1]\n  i += 1  \nleng2= A[i]\n\nprint(leng1*leng2)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\nans = []\nfor i, j in list(Counter(list(map(int, input().split()))).items()):\n    if j >= 4:\n        ans.append(i)\n    if j >= 2:\n        ans.append(i)\nif len(ans) >= 2:\n    ans.sort()\n    print((ans[-1] * ans[-2]))\nelse:\n    print((0))\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "import sys\nimport collections\n\nN = int(input())\nAN = list(map(int,input().split()))\n\ncount = collections.Counter(AN)\n\n\nedge1 = 0\nedge2 = 0\nfor c in sorted(list(count.keys()),reverse=True):\n  if count[c] >= 4:\n    if edge1 == 0:\n      print((c*c))\n      return\n    else:\n      print((edge1*c))\n      return\n  elif count[c] >= 2:\n    if edge1 == 0:\n      edge1 = c\n    else:\n      print((edge1*c))\n      return\nelse:\n  print((0))\n", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncnt_A = Counter(A)\n\nA_ = sorted([[k, v] for k, v in cnt_A.items() if v >= 2], reverse=True)\n\nif len(A_) == 0:\n    print(0)\nelif A_[0][1] >= 4:\n    print(A_[0][0] ** 2)\nelse:\n    print(A_[0][0] * A_[1][0])", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "N = int(input())\nA = [int(x) for x in input().split()]\n\npair = []\nunpair = set()\nfor a in A:\n    if a in unpair:\n        pair.append(a)\n        unpair.remove(a)\n    else:\n        unpair.add(a)\n\npair.sort()\npair.reverse()\nif len(pair) <= 1:\n    ans = 0\nelse:\n    ans = pair[0] * pair[1]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "N = int(input())\n\nA = list(map(int, input().split()))\n\nA.sort()\n\ns1 = 0\ns2 = 0\n\nat = -1\natc = 0\n\nfor a in A:\n    if at == a:\n        atc += 1\n\n    else:\n        if atc >= 4:\n            s1 = at\n            s2 = at\n        elif atc >= 2:\n            s2 = s1\n            s1 = at\n        \n        at = a\n        atc = 1\n\nif atc >= 4:\n    s1 = at\n    s2 = at\nelif atc >= 2:\n    s2 = s1\n    s1 = at\n\nprint((s1 * s2))\n", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}]