#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, j = 0;
  cin >> n;
  vector<long long> a(n), s(n + 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i = j) {
    int cnt = 0;
    j = i;
    while (j < n + 1 && s[i] == s[j]) {
      cnt++;
      j++;
    }
    if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
