#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a;
  vector<int> vec;
  vector<long> cum;
  unordered_map<long, int> map;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    vec.push_back(a);
  }
  cum.push_back(0);
  map[0] = 1;
  for (int i = 0; i < N; i++) {
    long c = cum[i] + vec[i];
    cum.push_back(c);
    if (map.count(c) == 0) {
      map[c] = 1;
    } else {
      map[c] += 1;
    }
  }
  int ans = 0;
  for (auto itr = map.begin(); itr != map.end(); ++itr) {
    if (itr->second > 1) {
      ans += (itr->second * (itr->second - 1)) / 2;
    }
  }
  cout << ans << endl;
}
