This page is still under construction.

Parts of this page are still being built. What you see may change.

Piano Competition

Interview

Time limit2sMemory limit1024 MB

Summary
Given N distinct judge scores, output the sum of all scores except the highest and the lowest.
Level

Easy2 of 10

Topics
Array, Implementation, Sorting
Solved
No attempts yet

Problem

Choyeoreum, who loves music, entered a competition that tests piano performance.

At the competition, N judges scored Choyeoreum's performance. The i-th judge (1 ≦ i ≦ N) gave Ai points. All of A1, A2, ..., AN are distinct. In this competition, Choyeoreum's total score is the sum of the scores of the N-2 judges other than the judges who gave the highest and lowest scores.

Given the scores from the N judges, write a program to find Choyeoreum's total score.

Input

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

N
A1 A2 … AN

Output

Print Choyeoreum's total score to standard output on 1 line.

Constraints

  • 3 ≦ N ≦ 50.
  • 0 ≦ Ai ≦ 100 (1 ≦ i ≦ N).
  • Ai ≠ Aj (1 ≦ i < j ≦ N).
  • All input values are integers.

Examples4

  1. Example 1

    Input
    3
    50 90 80
    
    Expected output
    80
    
  2. Example 2

    Input
    3
    72 100 64
    
    Expected output
    72
    
  3. Example 3

    Input
    5
    99 96 100 98 97
    
    Expected output
    294
    
  4. Example 4

    Input
    8
    0 80 40 75 90 70 85 100
    
    Expected output
    440