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