#include <bits/stdc++.h>
using namespace std;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
int main() {
  long long int ans = 0;
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i < n + 1; i++) cin >> a[i];
  long long int s[n + 1];
  s[0] = 0;
  for (long long int i = 1; i < n + 1; i++) s[i] = a[i] + s[i - 1];
  sort(s, s + n + 1);
  long long int cnt = 0;
  for (long long int i = 0; i < n + 1; i++) {
    if (s[i] == s[i + 1]) cnt++;
    if (s[i] != s[i + 1]) {
      long long int x = cnt * (cnt - 1) / 2;
      ans = ans + cnt;
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
