#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  cin >> n;
  map<long long, int> mp;
  mp[0LL] = 1;
  long long sum = 0LL;
  for (int i = int(0); i < int(n); ++i) {
    long long tmp;
    cin >> tmp;
    sum += tmp;
    if (mp.find(sum) == mp.end()) {
      mp[sum] = 1;
    } else {
      mp[sum] += 1;
    }
  }
  int cnt = 0;
  for (auto const& ele : mp) {
    if (ele.second > 1) cnt += ele.second * (ele.second - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
