Given an array A of length N. We say that a subarray (Al,Al+1,…,Ar) is good if for every l≤i<j<k≤r we can form a triangle (possible degenerate) with lengths Ai,Aj,Ak. In particular if 0≤r−l≤1 then the subarray is good. Count the number of good subarrays.
Input
The first line contains one integer - n (1≤n≤2⋅105).
The second line contains n integers - A1,A2,…,AN (1≤Ai≤109).
Output
Output the number of good subarrays.
The satisfying subarrays have (l,r)∈{(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(1,2),(2,3),(3,4),(4,5),(5.6),(3,5)}