#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<int, int> counter;
  int N;
  cin >> N;
  int S = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    S += a;
    counter[S] += 1;
  }
  long int res = 0;
  for (pair<int, int> p : counter) {
    if (p.first == 0) {
      res += p.second * (p.second + 1) / 2;
    } else {
      res += p.second * (p.second - 1) / 2;
    }
  }
  cout << res << "\n";
  return 0;
}
