#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int dx_8[] = {1, 1, 0, -1, -1, -1, 0, 1},
          dy_8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T>
inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <typename T>
inline T LCM(T a, T b) {
  T c = GCD(a, b);
  a /= c;
  return a * b;
}
template <typename T>
inline T nCr(T a, T b) {
  T i, r = 1;
  for (i = 1; i <= b; i++) {
    r *= (a + 1 - i);
    r /= i;
  }
  return r;
}
template <typename T>
inline T nHr(T a, T b) {
  return nCr(a + b - 1, b);
}
template <typename T>
inline T POW(T a, T b) {
  int i, r = 1;
  for (i = 1; i <= b; i++) {
    r *= a;
  }
  return r;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  long long a[200000];
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  long long sum[200000], mem = 0;
  map<int, long long> mp;
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    mem += a[i];
    sum[i] = mem;
    if (sum[i] == 0) ans++;
    mp[sum[i]]++;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second >= 2) ans += nCr(itr->second, 2LL);
  }
  cout << ans << "\n";
  return 0;
}
