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