P26544 [AtCoder] Piano Competition
普及
题目描述

Problem Description

Hatsuzuki, who loves music, participated in a piano competition to compete for playing skills.

In the competition, $ N $ judges scored Hatsuzuki's performance. The $ i $-th judge ($1 \leq i \leq N$) gave a score of $ A_i $. Note that $A_1, A_2, \dots, A_N$ are all distinct. The total score of Hatsuzuki in this competition is the sum of the scores from the $ N-2 $ judges excluding the highest and lowest scores.

Given the scores from the $ N $ judges, create a program to calculate Hatsuzuki's total score.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $\cdots$ $ A_N $

Output Format

Output the total score of Hatsuzuki on a single line to the standard output.

Sample Input and Output

Sample Input #1

3
50 90 80

Sample Output #1

80

Sample Input #2

3
72 100 64

Sample Output #2

72

Sample Input #3

5
99 96 100 98 97

Sample Output #3

294

Sample Input #4

8
0 80 40 75 90 70 85 100

Sample Output #4

440

Notes/Hints

Constraints

  • $3 \leq N \leq 50$.
  • $0 \leq A_i \leq 100$ ($1 \leq i \leq N$).
  • $A_i \neq A_j$ ($1 \leq i < j \leq N$).
  • All input values are integers.

Subtasks

  1. ($ 50 $ points) $ N = 3 $.
  2. ($ 50 $ points) No additional constraints.

Grading Notes

All submissions are graded on the judge system.

A submitted source code is considered correct for a subtask if it returns the correct result for all test input data corresponding to that subtask.

The score for each submission is the sum of the points for the subtasks that the submitted source code is considered correct for.

The score for this task is the maximum score of all submissions for this task.

The current score can be checked from the "My Score" tab in the "Submission Results".

Sample Explanation 1

The three judges gave scores of $ 50, 90, 80 $. Excluding the highest score $ 90 $ and the lowest score $ 50 $, the total score of Hatsuzuki is $ 80 $. This input example satisfies the constraints of all subtasks.

Sample Explanation 2

The three judges gave scores of $ 72, 100, 64 $. Excluding the highest score $ 100 $ and the lowest score $ 64 $, the total score of Hatsuzuki is $ 72 $. This input example satisfies the constraints of all subtasks.

Sample Explanation 3

Excluding the highest score $ 100 $ and the lowest score $ 96 $, the remaining three judges' scores are $ 99, 98, 97 $. Therefore, the total score of Hatsuzuki is $ 99 + 98 + 97 = 294 $. This input example satisfies the constraints of subtask 2.

Sample Explanation 4

Excluding the highest score $ 100 $ and the lowest score $ 0 $, the remaining six judges' scores are $ 80, 40, 75, 90, 70, 85 $. Therefore, the total score of Hatsuzuki is $ 80 + 40 + 75 + 90 + 70 + 85 = 440 $. This input example satisfies the constraints of subtask 2.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 50 90 80
样例输出
80