#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, cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s[i + 1] == s[i])
      cnt++;
    else {
      if (cnt) {
        ans += (cnt + 1) * cnt / 2;
        cnt = 0;
      }
    }
  }
  if (cnt) {
    ans += (cnt + 1) * cnt / 2;
    cnt = 0;
  }
  cout << ans << endl;
  return 0;
}
