#include <bits/stdc++.h>
using namespace std;
long long fac[51000], finv[51000], inv[51000];
void comint() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < 51000; ++i) {
    fac[i] = fac[i - 1] * i % 1000000000 + 7;
    inv[i] = 1000000000 + 7 -
             inv[1000000000 + 7 % i] * (1000000000 + 7 / i) % 1000000000 + 7;
    finv[i] = finv[i - 1] * inv[i] % 1000000000 + 7;
  }
}
long long com(long long n, long long k) {
  if (n > k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000000 + 7) % 1000000000 + 7;
}
bool is_prime(long long N) {
  for (long long i = 2; i * i < N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}
vector<long long> soinsubunkai(long long N) {
  vector<long long> tmp;
  long long num = N;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      long long j = N / i;
      if (is_prime(i)) {
        while (num % i == 0) {
          tmp.push_back(i);
          num /= i;
        }
      }
      if (is_prime(j)) {
        while (num % j == 0) {
          tmp.push_back(j);
          num /= j;
        }
      }
    }
  }
  return tmp;
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long modpow(long long a, long long n, long long m) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  long long ans = 0;
  cin >> N;
  vector<long long> vec(N);
  for (long long i = 0; i < (long long)N; ++i) cin >> vec[i];
  vector<long long> ruisekiwa(N + 1);
  set<long long> st;
  ruisekiwa[0] = 0;
  for (long long i = 0; i < (long long)N; ++i) {
    ruisekiwa[i + 1] = ruisekiwa[i] + vec[i];
  }
  sort((ruisekiwa).begin(), (ruisekiwa).end());
  map<int, int> mp;
  for (auto i : ruisekiwa) mp[i]++;
  for (auto i : mp) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
}
