import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = readln.split.to!(int[]);

  auto r = 0;
  auto rbt = redBlackTree!int();
  foreach (a; ai) {
    r += rbt.upperBound(a).array.length;
    rbt.insert(a);
  }

  writeln(r);
}