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

public class Stress_hack implements Runnable {
	public static void main(String[] args) {
		new Thread(new Stress_hack()).run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

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

		return in.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());
	}

	public int solve1(int[] a) {
		int n = a.length;
		int[][] next = new int[n][32];

		for (int i = 0; i < next.length; i++) {
			Arrays.fill(next[i], n);
		}

		for (int i = n - 1; i >= 0; i--) {
			for (int j = 0; j < 31; j++) {
				if (i != n - 1)
					next[i][j] = next[i + 1][j];

				if (((a[i] >> j) & 1) == 0) {
					next[i][j] = i;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			Arrays.sort(next[i]);
			int l = 0;
			for (int j = 1; j < next[i].length; j++) {
				if (next[i][j] != next[i][j - 1])
					next[i][l++] = next[i][j];
			}
			next[i] = Arrays.copyOf(next[i], l);
		}

		HashMap<Integer, TreeSet<Integer>> hm = new HashMap<Integer, TreeSet<Integer>>();
		int xor = 0;
		hm.put(0, new TreeSet<Integer>());
		for (int i = 0; i < next.length; i++) {
			xor ^= a[i];
			if (!hm.containsKey(xor)) {
				hm.put(xor, new TreeSet<Integer>());
			}
			hm.get(xor).add(i);
		}

		int ans = 0;
		xor = 0;
		for (int i = 0; i < next.length; i++) {
			int and = a[i];
			int l = i;
			for (int pos : next[i]) {
				if (pos == i)
					continue;
				int r = pos - 1;

				TreeSet<Integer> ts = hm.get(and ^ xor);

				if (ts != null)
					ans += ts.subSet(l, r + 1).size();

				if (pos == n)
					break;
				and &= a[pos];
				l = pos;
			}
			xor ^= a[i];
		}

		return ans;
	}

	public int solve2(int[] a) {
		int ans = 0;
		for (int i = 0; i < a.length; i++) {
			int xor = 0;
			int and = a[i];
			for (int j = i; j < a.length; j++) {
				xor ^= a[j];
				and &= a[j];
				if (xor == and)
					ans++;
			}
		}

		return ans;
	}

	public void run() {
		Random rnd = new Random(239);
		while (true) {
			int n = rnd.nextInt(10000) + 1;
			int[] a = new int[n];
			for (int i = 0; i < a.length; i++) {
				a[i] = rnd.nextInt(256);
			}
			System.err.println(solve1(a) + " " + n);
			if (solve1(a) != solve2(a)) {
				System.out.println(Arrays.toString(a));
				System.out.println(solve1(a) + " " + solve2(a));
				break;
			}
		}
	}
}
