#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
# ALDS1_5-D

=end

def cnt(l)
  n = l.length
  q = 0
  0.upto(l.length-1) {|i| 
    if l[i] > i then
      (i+1).upto(n-1) {|j|
        if l[j] < l[i] then
          q += 1
        end
      }
    end
  }
  return q
end

def mkidx(f)
  g = []
  0.upto(f.length-1){|i| g.push([f[i], i])}
  h = g.sort

  e=[]
  0.upto(h.length-1){|i| e.push(h[i][1])}

  return e
end

class Main
  def initialize()
    #fh = open("/home/muz/Downloads/ALDS1_5_B_in0.txt")
    fh = STDIN
    n = fh.gets.to_i
    a = fh.gets.chomp.split.map{|x| x.to_i}
    fh.close
    idx = mkidx(a)
    n = cnt(idx)

    puts n
  end
end

if $0 == __FILE__ then
  Main.new
end