#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e18;
vector<long long> fac(300001);
vector<long long> ifac(300001);
long long mpow(long long x, long long n) {
  long long ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return ans;
}
long long comb(long long a, long long b) {
  if (a == 0 && b == 0) return 1;
  if (a < b || a < 0) return 0;
  long long tmp = ifac[a - b] * ifac[b] % mod;
  return tmp * fac[a] % mod;
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<long long> S(N + 1);
  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1] + A[i - 1];
  }
  map<long long, long long> m;
  for (int i = 0; i < (N + 1); ++i) {
    m[S[i]]++;
  }
  fac[0] = 1;
  ifac[0] = 1;
  for (long long i = 0; i < 300000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % mod;
    ifac[i + 1] = ifac[i] * mpow(i + 1, mod - 2) % mod;
  }
  long long ans = 0;
  for (auto p : m) {
    auto value = p.second;
    ans += comb(value, 2);
  }
  cout << ans << endl;
  return 0;
}
