#include <bits/stdc++.h>
using namespace std;

int n;
map<long, long> mp;

int main() {
  cin >> n;
  long sum = 0;
  ++mp[0];
  
  while (n--) {
    long a;
    cin >> a;
    sum += a;
    ++mp[sum];
  }
  
  long ans = 0;
  for (auto&& p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
