use std::io; use std::str::FromStr; use std::str::Chars; use std::i32; use std::u8; use std::ascii::AsciiExt; use std::collections::HashMap; use std::collections::HashSet; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::VecDeque; use std::io::prelude::*; fn main() { let n = next_int() as usize; let a = next_ints(); let mut ans = 0; for i in 0..n { let mut temp = 0; for j in 0..i { if a[j] > a[i] { ans += 1; ans += temp; break; } else { temp += 1; } } } println!("{}",ans); } #[allow(dead_code)] fn next_string() -> String { let mut input = String::new(); io::stdin().read_line(&mut input).unwrap(); input } #[allow(dead_code)] fn next_strings() -> Vec { let input = next_string(); input.split_whitespace().map(|x| x.parse().unwrap()).collect() } #[allow(dead_code)] fn next_int() -> i64 { let input = next_string(); i64::from_str(input.trim()).unwrap() } #[allow(dead_code)] fn next_ints() -> Vec { let input = next_string(); input.split_whitespace().map(|x| x.parse().unwrap()).collect() }