import java.io.*;
import java.util.*;

public class gazmyas_bm {
	FastScanner in;
	PrintWriter out;

	int n;
	int[] a;
	int[] lastOdd;
	long ans;
	int[] tree;

	void add(int v, int l, int r, int need) {
		if (r == l) {
			tree[v]++;
		} else {
			int m = (l + r) / 2;
			if (m >= need)
				add(v * 2 + 1, l, m, need);
			else
				add(v * 2 + 2, m + 1, r, need);
			tree[v] = tree[v * 2 + 1] + tree[v * 2 + 2];
		}
	}

	int sum(int v, int l, int r, int needL, int needR) {
		if (needL > needR)
			return 0;
		if (l == needL && r == needR)
			return tree[v];
		int m = (l + r) / 2;
		return sum(v * 2 + 1, l, m, needL, Math.min(needR, m))
				+ sum(v * 2 + 2, m + 1, r, Math.max(m + 1, needL), needR);
	}

	void solve() {
		n = in.nextInt();
		a = new int[n];
		lastOdd = new int[n];
		tree = new int[4 * n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		int last = -1;
		for (int i = 0; i < n; i++)
			if (a[i] % 2 == 1)
				last = i;
			else
				lastOdd[i] = last;
		int[] pos = new int[n];
		for (int i = 0; i < n; i++)
			pos[a[i] - 1] = i;
		int start = n;
		if (n % 2 != 0)
			start--;
		for (int i = start - 1; i >= 0; i -= 2) {
			int p = pos[i];
			int to = lastOdd[p] - 1;
			if (to >= 0)
				ans += sum(0, 0, n - 1, 0, to);
			add(0, 0, n - 1, p);
		}
		out.println(ans);
	}

	void run() {
		try {
			in = new FastScanner(new File("gazmyas.in"));
			out = new PrintWriter(new File("gazmyas.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] args) {
		new gazmyas_bm().run();
	}
}