#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  vector<long long> cs(n + 1);
  unordered_map<long long, int> cnt;
  long long ans = 0;
  cnt[0] = 1;
  long long zero = 0;
  for (int i = 0; i < (int)(n); ++i) {
    cs[i + 1] = cs[i] + a[i];
    cnt[cs[i + 1]]++;
    if (a[i] == 0) zero++;
  }
  for (auto& e : cnt) {
    ans += e.second * (e.second - 1) / 2;
  }
  ans -= zero;
  cout << ans << endl;
  return 0;
}
