--配列型定義________________________________
arraymetatable = {}
setmetatable(arraymetatable, {__index=table})
arraymetatable.foreach = function(self, callback)
  for i = 1, #self do
    callback(self[i], i, self)
  end
  return nil
end
arraymetatable.map = function(self, callback)
  local newArray = Array()
  for i = 1, #self do
    newArray:insert(callback(self[i], i, self))
  end
  return newArray
end
arraymetatable.slice = function(self, begin, ed)
  local newArray = Array()
  for i = begin, ed do
    newArray:insert(self[i])
  end
  return newArray
end
arraymetatable.reduce = function(self, callback, initialvalue)
  local value = nil
  if(initialvalue == nil) then
    value = self[1]
    begin = 2
  else
    value = initialvalue
    begin = 1
  end
  for i = begin, #self do
    value = callback(value, self[i], i, self)
  end
  return value
end
arraymetatable.filter = function(self, callback)
  local newArray = Array()
  for i = 1, #self do
    if(callback(self[i])) then
      newArray:insert(self[i])
    end
  end
  return newArray
end
arraymetatable.tostring = function(self)
  return "["..self:concat(", ").."]"
end
function Array(...)
  local arr = {...}
  setmetatable(arr, {__index=arraymetatable, __tostring=arraymetatable.tostring})
  return arr
end
--配列型定義^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

function main()
  local n = tonumber(io.read())
  local str_a = io.read()
  local a = Array()
  for i in str_a:gmatch("%d+") do
    a:insert(tonumber(i))
  end
  a:sort(function(x, y) return y < x end)

  local maxs = {nil, nil}
  local decided = {false, false}
  for i = 1, #a do
    if not decided[1] then
      if not maxs[1] or a[i] ~= maxs[1] then maxs[1] = a[i] else decided[1] = true end
    elseif not decided[2] then
      if not maxs[2] or a[i] ~= maxs[2] then maxs[2] = a[i] else decided[2] = true end
    else
      break
    end
  end
  if decided[1] and decided[2] then print(maxs[1]*maxs[2]) else print(0) end
end

main()
