"use strict"; exports.__esModule = true; var fs = require("fs"); var BinaryIndexedTree = function (n) { var data = Array(n).fill(0); var add = function (p, x) { p++; var n = data.length; while (p <= n) { data[p - 1] += x; p += p & -p; } }; var sum = function (p) { var res = 0; while (p > 0) { res += data[p - 1]; p -= p & -p; } return res; }; var rangeSum = function (l, r) { return sum(r) - sum(l); }; return { add: add, sum: sum, rangeSum: rangeSum }; }; var main = function (args) { var input = args.trim().split("\n"); var n = +input.shift(); var p = input.shift().split(" ").map(function (x) { return +x; }); var bit = BinaryIndexedTree(n + 1); var ans = 0; p.forEach(function (x) { ans += bit.rangeSum(x + 1, n + 1); bit.add(x, 1); }); console.log(ans); }; main(fs.readFileSync('/dev/stdin', 'utf8'));