#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  vector<long long> b(n + 1);
  b[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    b[i] = a[i - 1] + b[i - 1];
  }
  long long ans = 0;
  map<int, int> mp;
  for (int i = 1; i < n + 1; i++) {
    mp[b[i]]++;
  }
  for (auto i : mp) {
    ans += i.second * (i.second - 1) / 2;
    if (i.first == 0) ans += i.second;
  }
  cout << ans << endl;
  return 0;
}
