#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long a[N], b[N];
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  b[0] = a[0];
  for (int i = 1; i < N; ++i) {
    b[i] = b[i - 1] + a[i];
  }
  map<int, int> ansmap;
  vector<int> arr;
  for (int i = 0; i < N; ++i) {
    if (ansmap[b[i]] == 0) {
      arr.push_back(b[i]);
    }
    ansmap[b[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < arr.size(); ++i) {
    if (ansmap[arr[i]] > 1) {
      ans += ansmap[arr[i]] * (ansmap[arr[i]] - 1) / 2;
    }
  }
  cout << ans + ansmap[0] << endl;
}
