#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  cin >> N;
  vector<long long> A;
  A.push_back(0);
  for (int i = 0; i < N; i++) {
    long long a;
    scanf("ll%d", &a);
    A.push_back(a);
  }
  for (int i = 1; i <= N + 1; i++) {
    A[i] += A[i - 1];
  }
  sort(A.begin(), A.end());
  A.push_back(-1000000008);
  long long ans = 0;
  long long temp = -1000000008;
  int cnt = 1;
  for (int i = 0; i <= N + 1; i++) {
    if (A[i] == temp)
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
      temp = A[i];
    }
  }
  cout << ans << '\n';
}
