Two element of an array A, A[i] and A[j] form an inversion if A[i]>A[j] and i<j.
You will be given the array A, you have to find sum of count of inversions for all subarrays.
INPUT:
First line contains a single integer N, which denotes the size of the array.
Second line contains N spaced integers denoting the elements of the array.
OUTPUT:
A single integer which is the desired answer modulo109+7.
CONSTRAINTS:
1≤N≤1051≤A[i]≤1018
Inversion count for subarray [0,0] = 0
Inversion count for subarray [0,1] = 0
Inversion count for subarray [0,2] = 0
Inversion count for subarray [0,3] = 1
Inversion count for subarray [1,1] = 0
Inversion count for subarray [1,2] = 1
Inversion count for subarray [1,3] = 3
Inversion count for subarray [2,2] = 0
Inversion count for subarray [2,3] = 1
Inversion count for subarray [3,3] = 0
Sum of inversion count for all subarrays = 9