CodeEff/ECCO huggingface dataset:
# Original solution
from heapq import heappop as pop
from heapq import heappush as push

INF = 10 ** 18

class edge:
  def __init__(self, to, cost):
    self.to = to
    self.cost = cost

V, E, r = list(map(int,input().split()))

G = [[] for i in range(V)]
#G[i]...頂点iからの辺、(行き先、コスト)
d = [0 for i in range(V)]
#d[i]...スタートからみた頂点iまでの最短距離

def dijkstra(s, V):
  que = []
  global d
  global G
  d = [INF for i in range(V)]
  d[s] = 0
  push(que, (0,s))

  while len(que):
    p = pop(que)
    v = p[1]
    if (d[v] < p[0]):
      continue
#    print(p)
    for i in range(len(G[v])):
      e = G[v][i]
      if d[e.to] > d[v] + e.cost:
        d[e.to] = d[v] + e.cost
        push(que, (d[e.to], e.to))

for i in range(E):
  s, t, c = list(map(int,input().split()))
  G[s].append(edge(t,c))
dijkstra(r, V)

for i in range(V):
  if d[i] != INF:
    print((d[i]))
  else:
    print("INF")


# Optimized solution
from heapq import heappush, heappop

INF = 10 ** 20

v_num, e_num, r = list(map(int, input().split()))
edges_lst = [[] for _ in range(v_num)]
dist_lst = [INF for _ in range(v_num)]

for _ in range(e_num):
  s, t, dist = list(map(int, input().split()))
  edges_lst[s].append((t, dist))

que = []
heappush(que, (0, r))
dist_lst[r] = 0

while que:
  dist, node = heappop(que)
  for to, cost in edges_lst[node]:
    if dist_lst[to] > cost + dist:
      dist_lst[to] = cost + dist
      heappush(que, (cost + dist, to))

for dist in dist_lst:
  if dist == INF:
    print("INF")
  else:
    print(dist)
# Original solution
import heapq

maxd = float('inf')
nv, ne, r = [int(n) for n in input().split(' ')]
vertices = {k: {} for k in range(nv)}
for i in range(ne):
    s, t, w = [int(n) for n in input().split(' ')]
    vertices[s][t] = w

q = []
heapq.heappush(q, (0, r))

dist = {v: maxd for v in vertices}
dist[r] = 0

while len(q):
    u = heapq.heappop(q)[1]

    for v in vertices[u]:
        alt = dist[u] + vertices[u][v]
        if alt < dist[v]:
            dist[v] = alt
            heapq.heappush(q, (alt, v))

[print(d) if d < maxd else print("INF") for v, d in dist.items()]


# Optimized solution
import heapq

nv, ne, r = map(int, input().split(' '))
vertices = [[] for i in range(nv)]
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    vertices[s].append((t, w))

q = []
heapq.heappush(q, (0, r))

dist = [float('inf')] * nv
dist[r] = 0

while len(q):
    u = heapq.heappop(q)[1]

    for t, w in vertices[u]:
        alt = dist[u] + w
        if alt < dist[t]:
            dist[t] = alt
            heapq.heappush(q, (alt, t))

[print(d) if d < float('inf') else print("INF") for d in dist]
# Original solution
import sys
from collections import deque

# 初期化
n_V, n_E, r = list(map(int, input().split()))

E = [[] for _ in range(n_V)]
D = [sys.maxsize for _ in range(n_V)]

# 入力
for i in range(n_E):
    v, e, d = list(map(int, input().split()))
    E[v].append((e, d))

#　各頂点への最短距離を求める処理
D[r] = 0
queue = deque([r])
visited = set()

while len(queue) != 0:
    current = queue.popleft()
    visited.add(current)

    for e, d in E[current]:
        if D[e] > D[current] + d:
            D[e] = D[current] + d
            if e in visited: visited.remove(e)

        if e not in queue and e not in visited:
            queue.append(e)

# 出力
for d in D:
    if d == sys.maxsize:
        print('INF')
    else:
        print(d)



# Optimized solution
import sys
from heapq import heappush
from heapq import heappop


# 入力
n_V, n_E, r = list(map(int, input().split()))

E = [[] for _ in range(n_V)]
for i in range(n_E):
    v, e, c = list(map(int, input().split()))
    E[v].append((e, c))


# 初期化
D = [sys.maxsize for _ in range(n_V)]
D[r] = 0

h = []
heappush(h, (D[r], r))


#　各頂点への最短距離を求める処理
while len(h) != 0:
    _, index = heappop(h)

    for e, c in E[index]:
        d = D[index] + c
        if D[e] > d:
            D[e] = d
            heappush(h, (d, e))


# 出力
for d in D:
    if d == sys.maxsize:
        print('INF')
    else:
        print(d)
# Original solution
v,e,r = list(map(int,input().split()))
d = [float('INF')]*v
d[r] = 0
edges=[]

for i in range(e):
  s,t,c = list(map(int,input().split()))
  edges.append([s,t,c])

for i in range(v):
  for s,v,c in edges:
    if d[v] > d[s]+c:
      d[v] = d[s]+c

for i in d:
  if i == float('inf'):
    print('INF')
  else:
    print(i)


# Optimized solution
v,e,r = list(map(int,input().split()))
d = [float('INF')]*v
d[r] = 0
edges=[]

for i in range(e):
  s,t,c = list(map(int,input().split()))
  edges.append([s,t,c])

for i in range(v):
  count = 0
  for s,v,c in edges:
    if d[v] > d[s]+c:
      count += 1
      d[v] = d[s]+c
  if count == 0:
    break

for i in d:
  if i == float('inf'):
    print('INF')
  else:
    print(i)
# Original solution
from collections import defaultdict
import heapq

vertice,edge,source = list(map(int,input().split(" ")))
link = defaultdict(dict)
weight = defaultdict(dict)
answer = [-1] * vertice
for e in range(edge):
    i,j,w = list(map(int,input().split(" ")))
    link[i] = link.get(i,set()) | {j}
    weight[i].update({j:w})
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
while queue:
    #print(queue)
    now_cost,here = heapq.heappop(queue)
    #print(now_cost,here,queue)
    if answer[here] > -1:
        continue
    answer[here] = now_cost

    #print(v,here,now_cost,not_went,queue)
    for nw in link[here]:
        if answer[nw] == -1:
            heapq.heappush(queue,(now_cost + weight[here][nw],nw))

for a in answer:
    print((a if a != -1 else "INF"))

# Optimized solution
import sys
from heapq import heappush, heappop
readline = sys.stdin.readline
from collections import defaultdict
vertices, edges, start = list(map(int, readline().split()))
connect = defaultdict(list)
cost = defaultdict(dict)
answer = ["INF" for n in range(vertices)]
for _ in range(edges):
    s, t, w = list(map(int, readline().split()))
    connect[s].append(t)
    cost[s].update({t:w})
 
 
now = start
weight = 0
p_queue = []
heappush(p_queue, (0, now))
visited = set()
while p_queue:
    weight, now = heappop(p_queue)
    if now in visited:
        continue
    visited |= {now}
    answer[now] = weight
    for c in connect[now]:
        if c not in visited:
            heappush(p_queue, (weight + cost[now][c], c))
for a in answer:
    print(a)
# Original solution
v,e,s=list(map(int,input().split()))
edge=[]
inf =1000000100
for i in range(v):
    edge.append([])

for i in range(e):
    vs,vt,d=list(map(int,input().split()))
    edge[vs].append((vt,d))
    
dis=[]
for i in range(v):
    dis.append(inf)

dis[s]=0

for j in range(v):
    for i in range(v):
        for (t,d) in edge[i]:
            if dis[t]>dis[i]+d:
                dis[t]=dis[i]+d

for i in range(v):
    if dis[i]>=inf:
        print("INF")
    else:
        print((dis[i]))

# Optimized solution
v,e,s=list(map(int,input().split()))
edge=[]
inf =1000000100
for i in range(v):
    edge.append([])

for i in range(e):
    vs,vt,d=list(map(int,input().split()))
    edge[vs].append((vt,d))
    
dis=[]
for i in range(v):
    dis.append(inf)

dis[s]=0

for j in range(v):
    update=False
    for i in range(v):
        for (t,d) in edge[i]:
            if dis[i]<inf and d<inf and dis[t]>dis[i]+d:
                dis[t]=dis[i]+d
                update=True
    if update==False: break

for i in range(v):
    if dis[i]>=inf:
        print("INF")
    else:
        print((dis[i]))
# Original solution
v, e, r = list(map(int, input().split()))
edgeList = [[0, 0, 0] for i in range(e)]
for i in range(e):
    a = list(map(int, input().split()))
    edgeList[i] = [a[2], a[0], a[1]]
 
 
rootList = [-1 for i in range(v)]
parent = [0 for i in range(v)]
lenList = [float("inf") for i in range(v)]
lenList[r] = 0
def getRoot(x):
    root = rootList[x]
    if root < 0:
        rootList[x] = x
    elif root != x:
        rootList[x] = getRoot(root)
    return rootList[x]
 
flag = True
while flag:
    flag = False
    edgeList.sort(key=lambda x: (x[0] + lenList[x[1]]))
    for e in edgeList:    # weight:e[0], e[1]->e[2]
        if e[2] == r:
            continue
        x = getRoot(e[1])
        y = getRoot(e[2])
        if x == r != y:
            parent[e[2]] = e[1]
            lenList[e[2]] = lenList[e[1]] + e[0]
            rootList[y] = r
            flag = True
            break
 
for i in lenList:
    if i == float("inf"):
        print("INF")
    else:
        print(i)

# Optimized solution
from heapq import heappush, heappop
N, M, s = list(map(int, input().split()))
Adj = [[] for i in range(N)]

for i in range(M):
    ui, vi, ci = list(map(int, input().split()))
    Adj[ui].append((vi, ci))

d = [float("inf")] * N
d[s] = 0
pq = [(0, s)]
fixed = 0

while pq:
    di, v = heappop(pq)

    if di > d[v]:
        continue

    for u, c in Adj[v]:
        if d[v] + c < d[u]:
            d[u] = d[v] + c
            heappush(pq, (d[u], u))

    fixed += 1

    if fixed == N - 1:
        break

for di in d:
    print((di if di != float("inf") else 'INF'))
# Original solution
import heapq
import math


def main():
    nvertices, nedges, s = list(map(int, input().split()))
    edges = [[] for i in range(nvertices)]
    for i in range(nedges):
        u, v, w = list(map(int, input().split()))
        edges[u].append((v, w))
    INF = float('inf')
    hq = []
    for i in range(nvertices):
        heapq.heappush(hq, ((0 if i == s else INF), i))
    heapq.heapify(hq)
    weights = [INF] * nvertices
    weights[s] = 0
    while hq:
        d, u = heapq.heappop(hq)
        if d > weights[u]:
            continue
        for v, w in edges[u]:
            if weights[u] + w < weights[v]:
                weights[v] = weights[u] + w
                heapq.heappush(hq, (weights[v], v))

    for w in weights:
        print(("INF" if math.isinf(w) else w))


main()

# Optimized solution
import heapq
import math


def main():
    nvertices, nedges, s = list(map(int, input().split()))
    edges = [[] for i in range(nvertices)]
    for i in range(nedges):
        u, v, w = list(map(int, input().split()))
        edges[u].append((v, w))
    INF = float('inf')
    hq = [(0, s)]
    weights = [INF] * nvertices
    weights[s] = 0
    while hq:
        d, u = heapq.heappop(hq)
        if d > weights[u]:
            continue
        for v, w in edges[u]:
            if weights[u] + w < weights[v]:
                weights[v] = weights[u] + w
                heapq.heappush(hq, (weights[v], v))

    for w in weights:
        print(("INF" if math.isinf(w) else w))


main()
# Original solution
from collections import deque
import sys
def solve():
    readline = sys.stdin.readline

    N, M, K = list(map(int, readline().split()))
    *A, = list(map(int, readline().split()))

    S = A[:]
    T = [0]*N
    zeros = [0]*N
    for k in range(K-1):
        que0 = deque()
        que1 = deque()
        T[:k+1] = zeros[:k+1]

        for i in range(k, N-1):
            a = S[i]
            while que1 and que1[-1] <= a:
                que0.pop()
                que1.pop()
            que0.append(i)
            que1.append(a)

            T[i+1] = que1[0] + A[i+1]*(k+2)

            if que0 and que0[0] <= i+1-M:
                que0.popleft()
                que1.popleft()
        S, T = T, S
    print((max(S)))
solve()

# Optimized solution
import sys
def solve():
    readline = sys.stdin.readline

    N, M, K = list(map(int, readline().split()))
    *A, = list(map(int, readline().split()))

    S = A[:]
    T = [0]*N
    Q0 = [0]*N; Q1 = [0]*N
    for k in range(2, K+1):
        s = t = 0

        for i in range(k-1, N):
            a = S[i-1]
            while s < t and Q1[t-1] <= a:
                t -= 1
            Q0[t] = i-1; Q1[t] = a
            t += 1

            T[i] = Q1[s] + A[i]*k

            if s < t and Q0[s] <= i-M:
                s += 1
        S, T = T, S
    print((max(S)))
solve()
# Original solution
from sys import stderr

def reads():
  return [int(x) for x in input().split()]

INF = 1 << 63

N, M, K = reads()
A = reads()

dp = A
for j in range(2, K+1):
  deq = [0] * N; l = r = 0
  q = [-INF] * N
  for i in range(N):
    # pop
    while l < r and deq[l] < i-M:
      l += 1
    # max
    q[i] = j * A[i] + (dp[deq[l]] if l < r else -INF)
    # append
    while l < r and dp[deq[r-1]] <= dp[i]:
      r -= 1
    deq[r] = i; r += 1
  dp = q

print((max(dp)))


# Optimized solution
from sys import stderr

def reads():
  return [int(x) for x in input().split()]

N, M, K = reads()
A = reads()

dp = [[0] * N, list(A)]
deq = [0] * N
for j in range(2, K+1):
  l = r = 0
  b = j & 1
  prev = dp[1-b]; curr = dp[b]
  for i in range(N):
    # pop
    while l < r and deq[l] < i-M:
      l += 1
    # max
    curr[i] = (j * A[i] + prev[deq[l]]) if (i >= j-1 and l < r) else 0
    # append
    while l < r and prev[deq[r-1]] <= prev[i]:
      r -= 1
    deq[r] = i; r += 1

print((max(dp[K & 1])))
# Original solution
from sys import stdin
N,K=[int(x) for x in stdin.readline().rstrip().split()]
if K == 1:
    print("YES")
else:
    if N+1-(K*2) >=0:
        print("YES")
    else:
        print("NO")

# Optimized solution
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
if len(list(range(1,N+1))[0::2]) >= K:
    print("YES")
else:
    print("NO")
# Original solution
n,k = list(map(int, input().split()))
if n==1 or n==2:
    if k==1:
        print('YES')
    else:
        print('NO')
elif n%2==0:
    cnt = n/2
    if(cnt>=k):
        print('YES')
    else:
        print('NO')
else:
    cnt = n//2 + 1
    if(cnt>=k):
        print('YES')
    else:
        print('NO')

# Optimized solution
n,k = list(map(int, input().split()))
x = (n+1)//2
bl = (x>=k)
ans = 'YES' if bl else 'NO'
print(ans)
# Original solution
from collections import Counter

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

c = Counter()

for ai in A:
    c[ai] += 1

more_than_2 = []
for k, v in list(c.items()):
    if v >= 4:
        more_than_2.append(k)
    if v >= 2:
        more_than_2.append(k)

if len(more_than_2) < 2:
    print((0))
else:
    more_than_2.sort(reverse=True)
    ans = more_than_2[0] * more_than_2[1]
    print(ans)



# Optimized solution
from collections import Counter

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

A.sort(reverse=True)
# print(A)
lines = []

cnt = 1
before = 'XXX'
for ai in A + ['YYY']:
    if ai == before:
        cnt += 1
    else:
        if cnt >= 4:
            lines.append(before)
            lines.append(before)
        elif cnt >=2:
            lines.append(before)

        if len(lines) >= 2:
            break
        
        cnt = 1
        before = ai


if len(lines) >= 2:
    print((lines[0] * lines[1]))
else:
    print((0))
# Original solution
from collections import Counter

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

A.sort(reverse=True)
# print(A)
lines = []

cnt = 1
before = 'XXX'
for ai in A + ['YYY']:
    if ai == before:
        cnt += 1
    else:
        if cnt >= 4:
            lines.append(before)
            lines.append(before)
        elif cnt >=2:
            lines.append(before)

        if len(lines) >= 2:
            break
        
        cnt = 1
        before = ai


if len(lines) >= 2:
    print((lines[0] * lines[1]))
else:
    print((0))

# Optimized solution
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    
    A.sort(reverse=True)
    lines = []
    prev = ''
    for ai in A:
        if ai == prev:
            lines.append(ai)
            prev = ''
        else:
            prev = ai

    if len(lines) >= 2:
        print((lines[0] * lines[1]))
    else:
        print((0))
  

if __name__ == "__main__":
    main()
# Original solution
from collections import Counter
N = int(eval(input()))
A = [int(Ai) for Ai in input().split()]
c = Counter(A).most_common()
c.sort(key=lambda x: x[0], reverse=True)
e1 = None
result = None
for k, v in c:
    if e1 is None and v >= 4:
        result = k**2
        break
    elif v >= 2:
        if e1 is None:
            e1 = k
        else:
            result = e1 * k
            break
if result is not None:
    print(result)
else:
    print((0))

# Optimized solution
N = int(eval(input()))
A = sorted([int(Ai) for Ai in input().split()], reverse=True)
x, y = 0, 0
current = A[0]
for Ai in A[1:]:
    if current is None or current != Ai:
        current = Ai
    else:
        if x == 0:
            x = current
            current = None
        else:
            y = current
            break
print((x * y))
# Original solution
from sys import stdin
input = stdin.readline

n = int(eval(input()))
re_nums = []
nums = []
A = list(map(int, input().split()))
for a in A:
    if a not in re_nums:
        re_nums.append(a)
    else:
        nums.append(a)
nums.sort(reverse=True)
l = len(nums)
ans = 0
if l < 2:
    ans = 0
else:
    l1 = nums[0]
    l2 = nums[1]
    if l2 == l1:
        if l > 3:
            if nums[2] == l2:
                ans = l1**2
            else:
                ans = l1*nums[2]
        else:
            ans = 0
    else:
        ans = l1*l2
print(ans)

# Optimized solution
from sys import stdin
input = stdin.readline

n = int(eval(input()))
dic = {}
A = list(map(int, input().split()))
for a in A:
    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1
nums = list(dic.items())
nums.sort(reverse = True)
l = len(nums)
l1 = 0
for i in range(l):
    if l1 == 0 and nums[i][1] >= 4:
        ans = nums[i][0]**2
        break
    elif l1 == 0 and nums[i][1] >= 2:
        l1 = nums[i][0]
    elif l1 > 0 and nums[i][1] >= 2:
        ans = l1*nums[i][0]
        break
else:
    ans = 0
print(ans)
# Original solution
from collections import Counter

eval(input())
ans = []
for i, j in list(Counter(list(map(int, input().split()))).items()):
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
if len(ans) >= 2:
    ans.sort()
    print((ans[-1] * ans[-2]))
else:
    print((0))


# Optimized solution
from collections import Counter

eval(input())
ans = [0, 0]
for i, j in list(Counter(list(map(int, input().split()))).items()):
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
ans.sort()
print((ans[-1] * ans[-2]))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort(reverse=True)
memo=[]

h=0; w=0
for element in a:
    if element in memo: pass
    else:
        memo.append(element)
        num=a.count(element)
        if num>=4 and h==0: h=w=element
        elif num>=2 and h==0: h=element
        elif num>=2 and w==0: w=element

ans=h*w
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort(reverse=True)

ans=[]
tmp=0
count=0
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; count=0
    else:
        if count%2==0: ans.append(el); tmp=el;
        count+=1

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)
# Original solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

pair = []
unpair = []
for a in A:
    if a in unpair:
        pair.append(a)
        unpair.remove(a)
    else:
        unpair.append(a)

pair.sort()
pair.reverse()
if len(pair) <= 1:
    ans = 0
else:
    ans = pair[0] * pair[1]
print(ans)

# Optimized solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

pair = []
unpair = set()
for a in A:
    if a in unpair:
        pair.append(a)
        unpair.remove(a)
    else:
        unpair.add(a)

pair.sort()
pair.reverse()
if len(pair) <= 1:
    ans = 0
else:
    ans = pair[0] * pair[1]
print(ans)
# Original solution
import collections
n = int(eval(input()))
a = list(map(int, input().split()))

rec_hen = 0
a_set = sorted(set(a), reverse=True)
for ai in a_set:
  ac = a.count(ai)
  if ac >= 4:
    if rec_hen != 0:
      print((rec_hen * ai))
      exit(0)
    print((ai * ai))
    exit(0)
  if ac >= 2:
    if rec_hen != 0:
      print((rec_hen * ai))
      exit(0)
    rec_hen = ai

print((0))

# Optimized solution
import collections
n = int(eval(input()))
a = list(map(int, input().split()))

rec_hen = 0
#a_set = sorted(set(a), reverse=True)
acc = collections.Counter(a)
ssa = sorted(list(acc.items()), key=lambda x: x, reverse=True)
for i, c in ssa:
  if c >= 4:
    if rec_hen != 0:
      print((rec_hen * i))
      exit(0)
    print((i * i))
    exit(0)
  if c >= 2:
    if rec_hen != 0:
      print((rec_hen * i))
      exit(0)
    rec_hen = i

print((0))
# Original solution
N = int(eval(input()))
bar = [int(x) for x in input().split()]
ls = []
a,b = 0,0
for x in bar:
    if x>b:
        if x in ls:
            ls.remove(x)
            if x>a:
                b = a
                a = x
            else:
                b = x
        else:
            ls.append(x)
print((a*b))


# Optimized solution
N = int(eval(input()))
bar = [int(x) for x in input().split()]
ls = set()
a,b = 0,0
for x in bar:
    if x>b:
        if x in ls:
            ls.remove(x)
            if x>a:
                b = a
                a = x
            else:
                b = x
        else:
            ls.add(x)
print((a*b))
# Original solution
import sys
input = sys.stdin.readline

n = int(eval(input()))
a = list(map(int, input().split()))
aset = set(a)
b = []
c = []
for i in aset:
    if a.count(i)>1:
        b.append(i)
    
    if a.count(i)>3:
        c.append(i)
b.sort()
c.sort()
m = len(b)
if m<2:
    if len(c)<1:
        print((0))
    else:
        print((c[-1]*c[-1]))
else:
    if len(c)<1:
        print((b[-1]*b[-2]))
    else:
        ans = max(b[-2]*b[-1],c[-1]*c[-1])
        print(ans)

# Optimized solution
import sys
input = sys.stdin.readline

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 1
j = 1
l = []
while i<n:
    if a[i]==a[i-1]:
        l.append(a[i])
        i+=2
    else:
        i+=1
l.append(0)
l.append(0)
print((l[0]*l[1]))
# Original solution
eval(input())
from collections import *
c=Counter(list(map(int,input().split())))
a=0
r=sorted(-k for k,v in list(c.items()) if v>1)
if len(r)>1: a=r[0]*r[1]
s=sorted(-k for k,v in list(c.items()) if v>3)
if s: a=max(a,s[0]**2)
print(a)

# Optimized solution
eval(input())
from collections import *
c=Counter(list(map(int,input().split())))
f=lambda x:sorted(-k for k,v in list(c.items()) if v>x)
a=0;r=f(1);s=f(3)
if len(r)>1: a=r[0]*r[1]
if s: a=max(a,s[0]**2)
print(a)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

x=0
y=0
a.sort()
i=1
while (i<len(a)):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i+=2
  else:
    i+=1

print((x*y))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

x=0
y=0
a.sort()
i=len(a)-1
while (i>0):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i-=2
  else:
    i-=1
  if x>0:
    break

print((x*y))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

x=0
y=0
a.sort()
i=len(a)-1
while (i>0):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i-=2
  else:
    i-=1
  if x>0:
    break

print((x*y))


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

x=0
y=0
a.sort()
i=n-1
while (i>0):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    if x>0:
      break
    i-=2
  else:
    i-=1

print((x*y))
# Original solution
import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] >= 4:
        ans = i * i if flag else a * i
        break
    elif stick_num[i] >= 2:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]
A.sort(reverse=True)

flag_h = True
flag_v = True
h, v = 0, 0

for i in A:
    if flag_h:
        if h == i:
            flag_h = False
        else:
            h = i
    elif flag_v:
        if v == i:
            flag_v = False
        else:
            v = i

if not (flag_v and flag_h):
    print((h * v))
else:
    print((0))