Given an array h_1, h_2, \ldots, h_n. Count the number of pairs of indices , 1 \le i < j \le n, such that the following conditions hold: h_i = h_j and \max_{i < k < j} h_k \le h_j.
The first line contains one integer (1 \le n \le 3 \cdot 10^5). The second line contains integers h_1, h_2, \ldots, h_n (1 \le h_i \le 10^6).
Print the number of pairs of indices that satisfy the given conditions.
In the first example, the valid pairs are: , , and .
Example 1
Example 2