import std.stdio, std.algorithm, std.range, std.random, std.array, std.string, std.conv;

int count_inversion(int[] xs) {
    if (xs.length == 1) return 0;
    auto ls = xs[0 .. $ / 2],
         rs = xs[$ / 2 .. $];
    int inv = 0;
    inv += count_inversion(ls);
    inv += count_inversion(rs);
    int i = 0, j = 0;
    auto ys = new int[xs.length];
    foreach (ref y; ys) {
        if (i == ls.length) {
            y = rs[j++];
        } else if (j == rs.length) {
            y = ls[i++];
        } else if (ls[i] < rs[j]) {
            y = ls[i++];
        } else {
            y = rs[j++];
            inv += (ls.length - i);
        }
    }
    ys.copy(xs);
    return inv;
}

void main() {
    int N = readln.chomp.to!int;
    auto xs = readln.chomp.split(" ").map!(to!int).array;
    writefln("%d", count_inversion(xs));
}