#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0, i_len = (n); i < i_len; i++) cin >> a[i];
  vector<long long> dp(n);
  map<int, int> ms;
  long long ans = 0;
  for (int i = 0, i_len = (n); i < i_len; i++) {
    if (i == 0) {
      dp[i] = a[i];
    } else {
      dp[i] = dp[i - 1] + a[i];
    }
    ms[dp[i]]++;
  }
  for (auto x : ms) {
    if (x.first == 0) {
      ans += x.second;
    } else {
      ans += ((long long)(x.second - 1) * (x.second - 1));
    }
  }
  cout << ans << endl;
  return 0;
}
