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

public class gazmyas_ats {
    StringTokenizer st;
    PrintWriter out;
    BufferedReader br;

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

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

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

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

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

    int[] place;

    public class Tree {
        private final int SIZE = 131072;
        int[] t;


        public Tree() {
            t = new int[SIZE * 2];
            Arrays.fill(t, 0);
        }

        public void inc(int pos) {
            pos += SIZE;
            t[pos]++;
            while (pos > 1) {
                pos /= 2;
                t[pos] = t[pos * 2] + t[pos * 2 + 1];
            }
        }

        public int get(int ll, int rr) {
            int l = ll + SIZE;
            int r = rr + SIZE;
            int ans = 0;
            while (l <= r) {
                if ((l & 1) == 1) {
                    ans += t[l];
                    l++;
                }
                if ((r & 1) == 0) {
                    ans += t[r];
                    r--;
                }
                l /= 2;
                r /= 2;
            }
            return ans;
        }
    }

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        place = new int[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        int cnt = -1;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                if (cnt == -1 || a[i - 1] % 2 == 1) {
                    cnt++;
                }
                place[a[i]] = cnt;
            }
        }
        Tree t = new Tree();
        int ans = 0;
        for (int i = 1; i <= n / 2; i++) {
            t.inc(place[i * 2]);
            ans += t.get(place[i * 2] + 1, n);
        }
        out.println(ans);
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader("gazmyas.in"));
            out = new PrintWriter("gazmyas.out");

            solve();

            br.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
