Simple Permutation Problem
InterviewTime limit1sMemory limit1024 MB
Count position pairs i < j in a permutation where both values are larger than every element strictly between them.
Problem
A permutation of length is given. A permutation of length uses each integer from to exactly once, arranged in any order. Count the pairs that satisfy both conditions below.
is the -th element of .
Input
The first line contains , the length of the permutation.
The second line contains integers , separated by spaces.
Output
Print the answer to the problem.