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