MergeSort

2.6

10 votes
Very-Easy
Problem

Given an array A on size N, you need to find the number of ordered pairs such that and .

Input:
First line contains one integer, N, size of array.
Second line contains N space separated integers denoting the elements of the array A.

Output:
Print the number of ordered pairs such that and .

Constraints:

Sample Input
5
1 4 3 2 5
Sample Output
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the sample test case, the 3 ordered pairs will be , and .
but
but
but

Editor Image

?