#include <bits/stdc++.h>
using namespace std;
int a[200001];
long long s[200001];
int BinarySearch(int n, int i, long long val) {
  int x = i + 2, y = n, ans = n + 1;
  while (x <= y) {
    int mid = x + (y - x) / 2;
    if (s[mid] >= val) {
      ans = mid, y = mid - 1;
    } else {
      x = mid + 1;
    }
  }
  return ans;
}
long long Count(int n) {
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    s[i] = a[i] + s[i - 1];
  }
  for (int i = 1; i <= n; ++i) {
    int j = BinarySearch(n, i, s[i] + a[i]);
    if (j > n) {
      continue;
    }
    long long sum = s[j - 1] - s[i - 1];
    for (; j <= n; ++j) {
      sum += a[j];
      if (sum > 4ll * a[i]) {
        break;
      }
      if (2ll * (a[i] | a[j]) == sum && a[j] < a[i]) {
        ++ans;
      }
    }
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  long long ans = Count(n);
  reverse(a + 1, a + n + 1);
  ans += Count(n);
  printf("%lld\n", ans);
  return 0;
}
