#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long int> A(N + 1, 0);
  A[0] = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i + 1];
    A[i + 1] += A[i];
  }
  int answer = 0;
  sort(A.begin(), A.end());
  int temp = 1;
  for (int i = 0; i < N; ++i) {
    if (A[i] == A[i + 1]) {
      answer += temp;
      ++temp;
    } else {
      temp = 1;
    }
  }
  cout << answer << endl;
}
