CF1223G.Wooden Raft

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've already cut several trees and prepared it to the point that now you have nn logs and the ii -th log has length aia_i .

The wooden raft you'd like to build has the following structure: 22 logs of length xx and xx logs of length yy . Such raft would have the area equal to xyx \cdot y . Both xx and yy must be integers since it's the only way you can measure the lengths while being on a desert island. And both xx and yy must be at least 22 since the raft that is one log wide is unstable.

You can cut logs in pieces but you can't merge two logs in one. What is the maximum area of the raft you can craft?

输入格式

The first line contains the only integer nn ( 1n51051 \le n \le 5 \cdot 10^5 ) — the number of logs you have.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 2ai51052 \le a_i \le 5 \cdot 10^5 ) — the corresponding lengths of the logs.

It's guaranteed that you can always craft at least 2×22 \times 2 raft.

输出格式

Print the only integer — the maximum area of the raft you can craft.

输入输出样例

  • 输入#1

    1
    9
    

    输出#1

    4
    
  • 输入#2

    9
    9 10 9 18 9 9 9 28 9
    

    输出#2

    90
    

说明/提示

In the first example, you can cut the log of the length 99 in 55 parts: 2+2+2+2+12 + 2 + 2 + 2 + 1 . Now you can build 2×22 \times 2 raft using 22 logs of length x=2x = 2 and x=2x = 2 logs of length y=2y = 2 .

In the second example, you can cut a4=18a_4 = 18 into two pieces 9+99 + 9 and a8=28a_8 = 28 in three pieces 10+9+910 + 9 + 9 . Now you can make 10×910 \times 9 raft using 22 logs of length 1010 and 1010 logs of length 99 .

首页