Author:  Антон Карабанов, И. Блинов, А. Баранов  Time limit:  1 sec  
Input file:  Standard input  Memory limit:  512 Mb  
Output file:  Standard output 
Zhenya drew a regular ngon on the board, labeled its vertices with numbers clockwise in ascending order: "1 2 3 ... n". Nikita came up and rearranged the numbers in the signature, erased all sides of Zhenya's figure and connected the vertices in the resulting new order (including the first and last vertices). Now a closed broken line flaunts on the board. How many pairs of line segments intersect?
The first line of the input contains single integer n. The second line contains n numbers a_{1}, a_{2}… a_{n} — a permutation of the polygon's vertices.
Output a single nonnegative integer — the answer to the problem question.
3 ≤ n ≤ 10^{5}
No.  Standard input  Standard output 

1 


2 


3 


4 

