#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 1000000;
const double PI = 3.14159265359;
const int MAX = 100010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < (n); i++) cin >> a[i];
  set<long long> se;
  vector<long long> s(n + 1, 0);
  for (long long i = 0; i < (n); i++) {
    s[i + 1] = s[i] + a[i];
  }
  map<long long, long long> mp;
  for (long long i = 0; i < (n + 1); i++) {
    se.insert(s[i]);
    mp[s[i]]++;
  }
  COMinit();
  long long ans = 0;
  for (set<long long>::iterator itr = se.begin(); itr != se.end(); itr++) {
    ans += COM(mp[*itr], 2);
  }
  cout << ans << endl;
  return 0;
}
