Problem list
Log in
#r03211 · Online Judge > GoldOJ

Best Digit-Sum Score

Silver III 2.0 s 1024 MB

An array of $N$ integers is given. Choosing two distinct positions $i \ne j$, the score is the digit sum of $a_i \times a_j$. Print the maximum achievable score.

Input

Line 1: $N$ ($2 \le N \le 100000$). Line 2: $a_1, \dots, a_N$ ($1 \le a_i \le 999$).

Output

Print the maximum digit-sum score over all pairs.

Example 1

Input
2
3 8
Output
6
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code