In professional diving competitions, athletes are evaluated by a panel of $N$ judges. To prevent biased judging, the scoring system uses a special rule: the highest single score and the lowest single score are discarded. The diver's final score is the sum of the remaining $N - 2$ scores.

Note that if several judges give the same highest score, only one of them is discarded. The same rule applies to the lowest score.

Given the scores awarded to a diver by the $N$ judges, calculate the diver's final score.

Input

The first line contains one integer $N$, the number of judges.
The second line contains $N$ integers $s_1, s_2, \dots, s_N$, the scores awarded by the judges.

Output

Print a single integer, the diver's final score.

Constraints

For all cases, $3 \le N \le 10^5$ and $0 \le s_i \le 10^4$ for all $1 \le i \le N$.

Subtasks

Subtask 1 (50%): $N = 3$
Subtask 2 (50%): No additional constraints

Sample Test Cases

Input Output
5
8 6 9 7 6
21
The highest score $9$ and the lowest score $6$ are discarded, so the final score is $8 + 7 + 6 = 21$.
5
7 9 9 3 3
19
Only one $9$ and one $3$ are discarded, so the final score is $7 + 9 + 3 = 19$.
3
5 5 5
5
One $5$ is discarded as the highest score and another $5$ as the lowest score, so the final score is $5$.
Click to copy.

Scoring: Per Subtask
Authored by hclee and s17r28
Appeared in 2026 Wah Yan Interschool Olympiad in Informatics 🤯🥷⚡🧠🏆