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