#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N + 1);
  A[0] = 0;
  int sum = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    sum += A[i];
    A[i] = sum;
  }
  sort(A.begin(), A.end());
  long ans = 0;
  int count = 0;
  int before = -1;
  for (const int a : A) {
    if (a != before) {
      ans += count * (count - 1) / 2;
      before = a;
      count = 0;
    }
    ++count;
  }
  ans += count * (count - 1) / 2;
  cout << ans << '\n';
  return 0;
}
