/*
If this question is cyclically cracked, it will be TLE. There are two methods: 1. Merge and sort. 2. Tree array.
This question shows the Merge Sorting method: the main idea of splitting is to continue to be divided into two parts, and the two adjacent arrays are merged.
Obtain the minimum number of steps.
*/
# Include <cstdio>
# Include <cstring>
Long a [500010], B [500010], num;
Long merge_sort (long * A, int x, int y, long * T)
{
If (y-x> 1)
{
Int m = (x + y)/2;
Int p = x, q = m, I = x;
Merge_sort (A, x, m, T );
Merge_sort (A, m, y, T );
Int ps = x;
While (p <m | q <y)
{
If (q> = y | (p <m & A [p] <= A [q])
T [I ++] = A [p ++], ps ++;
Else
{
Num + = m-p;
// Printf ("% d. \ n", num, A [p], A [q]);
T [I ++] = A [q ++];
}
}
For (int I = x; I <y; I ++)
A [I] = T [I];
}
}
Int main ()
{
Int n;
While (scanf ("% d", & n)
{
For (int I = 0; I <n; I ++)
Scanf ("% lld", & a [I]);
Num = 0;
Memset (B, 0, sizeof (B ));
Merge_sort (a, 0, n, B );
Printf ("% lld \ n", num );
}
Return 0;
}