LearnToCP
Sign in
Navigation
HomeRoadmapProblemsAbout Us
Theory
Basics
Your First ProgramData types and IOC++ syntaxModuloFunctionsVectorsMatricesTime Complexity
Sorting
SortingCounting sortRadix Sort
Optimization Techniques
Two PointersSum of numbers 1 to nPrefix sumBinary SearchGreedyBinary Search Functions
Binary Numbers
Binary NumbersNumbers in codeBitwise Operations
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of Eratosthenes
Data Structures
StringsStackQueue
Dynamic Programming
About DPDP problems

Number of Increasing Segments

EasyProblem #13
Time LimitMemoryInputOutput
1 s64 MBstdinstdout

Watch out for the size of the answer.

An array a of n integers is given. A segment of the array is a group of consecutive elements. A segment is increasing if every element in it is strictly smaller than the one after it, and it has at least two elements. Your task is to count the increasing segments of the given array.

Formally, you are counting the pairs of positions (p,q), 0≤p<q<n, for which ap​<ap+1​<…<aq​.

Input

The first line contains a single integer t - the number of testcases.

  • The first line of each testcase contains an integer n - the number of elements.
  • The next line contains n integers a0​,a1​,…,an−1​ - the elements of the array.

Output

For every testcase print a single line with the number of increasing segments.

Example

Input
2
5
1 3 4 -2 10
4
2 2 3 1
Output
4
1

In the first testcase the increasing segments are [1,3], [1,3,4], [3,4] and [−2,10]. In the second testcase the only one is [2,3] - the pair of equal elements [2,2] does not count, the increase must be strict.

Constraints

1≤t≤1000
2≤n≤2⋅105
−109≤ai​≤109
n1​+n2​+…+nt​≤2⋅105


This problem was adapted, with permission, from Broj rastućih segmenata, authored by Društvo matematičara Srbije and Fondacija Petlja.

Submit your solution

Sign in to submit your solution and track your progress.

Sign in to submit