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

public class gazmyas_pk {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	class Node {
		int x, y;
		Node l, r;
		int size;

		Node(int x) {
			this.x = x;
			y = new Random(x).nextInt();
			size = 1;
			l = null;
			r = null;
		}

		public void update() {
			size = 1;
			if (l != null)
				size += l.size;
			if (r != null)
				size += r.size;
		}
	}

	Node[] split(Node node, int key) {
		if (node == null) {
			return new Node[] { null, null };
		}
		if (key < node.x) {
			Node[] res = split(node.l, key);
			node.l = res[1];
			node.update();
			return new Node[] { res[0], node };
		}
		Node[] res = split(node.r, key);
		node.r = res[0];
		node.update();
		return new Node[] { node, res[1] };
	}

	Node merge(Node l, Node r) {
		if (l == null)
			return r;
		if (r == null)
			return l;
		if (l.y > r.y) {
			l.r = merge(l.r, r);
			l.update();
			return l;
		} else {
			r.l = merge(l, r.l);
			r.update();
			return r;
		}
	}

	public void solve() throws IOException {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Node root = null;
		ArrayList<Node> addition = new ArrayList<gazmyas_pk.Node>();
		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				Node[] res = split(root, a[i]);
				if (res[1] != null)
					ans = ans + res[1].size;
				root = merge(res[0], res[1]);
				addition.add(new Node(a[i]));
			} else {
				for (Node c : addition) {
					Node[] res = split(root, c.x);
					res[0] = merge(res[0], c);
					root = merge(res[0], res[1]);
				}
				addition = new ArrayList<gazmyas_pk.Node>();
			}
		}
		out.println(ans);
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("gazmyas.in"));
			out = new PrintWriter("gazmyas.out");

			solve();

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

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