#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
int main() {
  int n, x;
  scanf("%d", &n);
  mp.clear();
  mp[0]++;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    sum += x;
    mp[sum]++;
  }
  long long ans = 0;
  map<long long, long long>::iterator it = mp.begin();
  for (; it != mp.end(); it++) {
    long long t = it->second;
    ans += (t * (t - 1) / 2);
  }
  cout << ans << endl;
  return 0;
}
