#include <bits/stdc++.h> #define ll long long using namespace std; int li[1000001]; int li2[1000001]; ll ans = 0; void merge_sort(int L, int R) { if (L == R) return; int mid = (L + R) >> 1; merge_sort(L, mid); merge_sort(mid + 1, R); int l = L, ln = mid; int r = mid + 1, rn = R; int st = L; ll cnt = 0; while (l <= ln && r <= rn) { if (li[l] <= li[r]){ ans += cnt; li2[st++] = li[l++]; } else{ cnt++; li2[st++] = li[r++]; } } while (l <= ln){ ans += cnt; li2[st++] = li[l++]; } while (r <= rn) li2[st++] = li[r++]; for (int i = L; i <= R; i++) li[i] = li2[i]; }; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &li[i]); merge_sort(1, n); printf("%lld", ans); }