#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  vector<int64_t> sum(n, a[0]);
  for (int i = 0; i < n - 1; i++) {
    sum[i + 1] = sum[i] + a[i + 1];
  }
  map<int, int> get;
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    get[sum[i]]++;
  }
  for (auto c : get) {
    int v = c.first;
    int count = c.second;
    if (v == 0) {
      ans += count;
    } else {
      ans += count * (count - 1) / 2;
    }
  }
  cout << ans << endl;
}
