#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T keta(T num) {
  T k = 0;
  while (num > 0) {
    num /= 10;
    k++;
  }
  return k;
}
template <typename T>
void vdebug(vector<T> v) {
  for (auto vv : v) {
    cout << vv << " ";
  }
  cout << endl;
}
template <typename T>
void adebug(T arr[], long long n) {
  for (long long i = 0; i <= n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
template <typename T1, typename T2>
void mdebug(map<T1, T2> mp) {
  cout << "mdebug" << endl;
  for (auto const& m : mp) {
    cout << m.first << " " << m.second << endl;
  }
}
void ans(bool b) {
  if (b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ans2(bool b) {
  if (b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a[200010], b[200010];
  b[0] = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i + 1] = a[i] + b[i];
  }
  map<long long, long long> cnt;
  long long mark = 0;
  for (long long i = 1; i <= n; i++) {
    if ((1LL << b[i]) & mark || b[i] == 0) {
      cnt[b[i]]++;
    } else {
      mark |= (1LL << b[i]);
    }
  }
  long long res = 0;
  for (auto const& c : cnt) {
    res += ((c.second + 1) * c.second) / 2;
  }
  cout << res << endl;
  return 0;
}
