#include <bits/stdc++.h>
using namespace std;
int N;
int A[200002];
long long S[200002];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i <= N; i++) {
    if (i == 0) {
      S[0] = 0;
    } else {
      S[i] = S[i - 1] + A[i];
    }
  }
  sort(S, S + N + 1);
  int ans = 0;
  int cnt = 1;
  for (int i = 1; i <= N; i++) {
    if (S[i] == S[i - 1]) {
      cnt++;
    } else {
      ans += (cnt * (cnt - 1)) / 2;
      cnt = 1;
    }
  }
  ans += (cnt * (cnt - 1)) / 2;
  cout << ans;
  return 0;
}
