I. Substring
time limit per test
0.65 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

Given an array of positive integers, count the number of substrings with the following properties:

  • it has length of at least 2
  • its extremities are bigger than the other elements (e.g. 2 2 3 is bad, but 3 2 3 is good)
Input

The input will contain on the first line one integer (. The second line contains numbers and the array for which we want the solution is obtained as following: . Both arrays and are 0-indexed.

Output

The output will contain the number of substrings with the given properties.

Example
Input
3
3 2 3
Output
2