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