#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
long long N;
long long A[200000];
long long S[200000];
int main() {
  cin >> N;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  S[0] = A[0];
  for (int i = 1; i < N; i++) {
    S[i] = S[i - 1] + A[i];
  }
  sort(S, S + N);
  long long now = 0;
  while (S[now] != 0) {
    now++;
  }
  long long cnt = 0;
  while (S[now] == 0) {
    now++;
    cnt++;
  }
  ans += cnt;
  now = 0;
  while (now < N) {
    long long cnt = 1;
    while (now < N - 1 && S[now] == S[now + 1]) {
      now++;
      cnt++;
    }
    ans += cnt * (cnt - 1) / 2;
    now++;
  }
  cout << ans << endl;
  return 0;
}
