LearnPy Hub
← Arena
EasyRating 1000

Between Min and Max

Take the first position of the minimum and the first position of the maximum. Print the sum of the numbers strictly between them (0 if they are next to each other or the same).

Input

n, then n integers.

Output

One integer.

Sample 1

Input
6
4 1 3 5 9 2
Output
8

Sample 2

Input
3
1 2 3
Output
2
solution.py
Output appears here
Between Min and Max · Python Arena problem · LearnPy Hub