#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
int main() {
  int n;
  long long ans = 0, sum = 0;
  cin >> n;
  mp[1000000000] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    int temp = sum + 1000000000;
    if (mp.count(temp) == 0) {
      mp[temp] = 1;
    } else {
      ans += mp[temp];
      mp[temp]++;
    }
  }
  cout << ans << endl;
  return (0);
}
