import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int[] compact(int[] xs) {
    auto ys = xs.dup;
    ys.sort;

    int[int] m;
    foreach (i, y; ys) {
        m[y] = cast(int) i + 1;
    }

    auto ret = new int[xs.length];
    for (int i = 0; i < xs.length; i++)
        ret[i] = m[xs[i]];
    return ret;
}

// long calc(int[] xs) {
//     // auto n = xs.maxElement;
//     auto n = xs.reduce!max;
//     auto bit = new BinaryIndexedTree(n);
//     long ans = 0;
//     for (int i = 0; i < xs.length; i++) {
//         ans += i - bit.sum(xs[i]);
//         bit.add(xs[i], 1);
//     }
//     return ans;
// }

long calc2(int[] xs) {
    // auto n = xs.maxElement;
    auto n = xs.reduce!max;
    auto bit = new BinaryIndexedTree(n);
    long ans = 0;
    for (int i = 0; i < xs.length; i++) {
        int x = xs[i];
        ans += x - 1 - bit.sum(x);
        bit.add(x, 1);
    }
    return ans;
}

void main() {
    readln;
    auto xs = readints;

    auto ans = calc2(compact(xs));
    writeln(ans);
}

class BinaryIndexedTree {
    private int[] _data;

    this(int n) {
        _data = new int[n + 1];
    }

    /// [1, p] ??????(1 based)
    int sum(int p) {
        assert(0 < p && p < _data.length);

        int s = 0;
        while (p > 0) {
            s += _data[p];
            p -= p & -p;
        }
        return s;
    }

    /// p ????????? x ????????????(1 based)
    void add(int p, int x) {
        assert(0 < p && p < _data.length);

        while (p < _data.length) {
            _data[p] += x;
            p += p & -p;
        }
    }
}