Simple sum
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Nikhat arranged the numbers in ascending order. Later Hussein came and swapped some of these numbers. Now we have some mixed sequence of numbers from to .
Calculate the following sum for this sequence:
Simply put, you need to find the sum of all the minimum numbers in all subsequences of a given sequence.
The min
function finds the minimum of the given numbers.
Input
The first line contains one integer - the number of numbers in the sequence. The second line contains integers - elements of the sequence.
Output
Print the required amount corresponding to the given sequence.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 737
Acceptance rate 21%