INCINT
Problem
You are given a sequence consisting of natural numbers: , , , . The task is to find the number of intervals of consecutive terms in the sequence that are in (not necessarily strictly) increasing order.
In other words, in how many different ways can we choose two positions and in the array, where , such that .
Input:
The first line of the input will contain an integer , the number of terms in the sequence. The second line of the input will contain the terms of the sequence, separated in pairs by a single space.
Output:
The output should consist of exactly one line containing exactly one integer: the desired number of intervals of consecutive terms in the sequence that are in increasing order.
Constraints
- .
- για κάθε
- Time Limit: sec.
Memory Limit: MB.
For test cases with a total weight of , .
- For test cases with a total weight of , .
Examples of Input - Output Files:
1st
STDIN (incint.in)
7
10 13 15 12 19 17 17
STDOUT (incint.out)
12
Explanation of the first example
The intervals we can choose are:
- intervals with only one term (i.e., with ): , , , , , , .
- intervals with two terms: , , , .
- interval with three terms: .
2nd
STDIN (incint.in)
5
5 4 3 2 1
STDOUT (incint.out)
5
Explanation of the second example
The terms of the sequence are in strictly decreasing order, so there are no other intervals we can choose, except for the 5 intervals with only one term (i.e., with ): , , , , .
Comments