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