#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, N, bf = 1, cnt = 0, ans = 0;
  cin >> N;
  vector<int> a(N), s(N + 1, 0);
  for (i = 0; i < N; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  sort(s.begin(), s.end());
  for (i = 0; i < N + 1; i++) {
    if (bf == s[i]) {
      cnt++;
    } else {
      ans += cnt * (cnt + 1) / 2;
      cnt = 0;
      bf = s[i];
    }
  }
  ans += cnt * (cnt + 1) / 2;
  cout << ans << endl;
}
