#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long MOD = 1000000007;
const long long INF = 1e10;
const long long MAX_N = 201010;
long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_N; i++) {
    fac[i] = fac[i - 1] * i;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] / (fac[k] * fac[n - k]);
}
long long dx[4] = {0, 0, -1, 1};
long long dy[4] = {-1, 1, 0, 0};
char c[310][310];
long long dp[101];
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> sum(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i] = a[i];
  }
  for (long long i = 0; i < n - 1; ++i) {
    sum[i + 1] += sum[i];
  }
  map<long long, long long> mp;
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    mp[sum[i]]++;
    if (sum[i] == 0) ans++;
  }
  COMinit();
  for (auto p : mp) {
    long long x = p.second;
    if (x > 1) {
      ans += COM(x, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
