#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N + 1, 0);
  set<long long> B;
  B.insert(0);
  for (int i = 1; i <= N; i++) {
    long long tmp;
    cin >> tmp;
    A[i] = A[i - 1] + tmp;
    B.insert(A[i]);
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for (long long i : B) {
    int tmp = count(A.begin(), A.end(), i);
    ans += (tmp * (tmp - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
