#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  string in;
  cin >> n;
  vector<int> A(n);
  long long buf, score;
  map<long long, long long> mapA;
  mapA[0] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> in;
    buf += stoll(in);
    score += mapA[buf];
    mapA[buf]++;
  }
  cout << score;
  return 0;
}
