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

public class gazmyas_ats_slow {
    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_slow().run();
    }

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        int[] 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;
            }
        }

        int ans = 0;
        for (int i = 1; i <= n / 2; i++) {
            for (int j = i + 1; j <= n / 2; j++) {
                if (place[j * 2] < place[i * 2]) {
                    ans++;
                }
            }
        }
        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);
        }
    }
}
