LearnToCP
Sign in
Navigation
HomeRoadmapProblemsAbout Us
Theory
Contest Knowledge
Selecting an IDE
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 FunctionsBinary Search by AnswerDivide and Conquer
Binary Numbers
Binary NumbersNumbers in codeBitwise OperationsBitmasks
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of EratosthenesModified Sieve
Data Structures
StringsStackQueueMapsSetsPriority QueueCustom Criteria for FunctionsSegment TreesFenwick TreesSparse TablesUnion Find
Combinatorics
Addition PrincipleMultiplication PrincipleCombinatoric ObjectsInclusion Exclusion Principle
Geometry
Geometry BasicsVectorsCross and Dot ProductLinesPolygonsAnglesPoint in PolygonDistances and Intersection PointsConvex HullCircles
Recursion
PointersRecursionGenerating Combinatoric Objects
Dynamic Programming
About DPTree DPBitmask DPDigit DP
Graph Theory
GraphsDFS and BFSShortest PathsTreesTopological SortingDijkstra's AlgorithmMinimum Spanning TreesShortest Path Algorithms
Advanced Graph Theory
BiconnectivityStrongly Connected ComponentsBipartite GraphGraph FlowAugmenting PathsFlow - Minimum Cut DualityHeavy-Light DecompositionCentroid Decomposition
Advanced Data Structures
2D and 3D Segment TreesLazy PropagationImplicit Segment TreesPersistent Segment TreesLowest Common AncestorTrieBalanced Binary Search TreesMo's Algorithm

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