#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  int A[N + 1];
  memset(A, 0, sizeof(A));
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] += A[i - 1];
  }
  sort(A, A + N + 1);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll cnt = 0;
    int j = i;
    while (A[i] == A[j]) {
      cnt++;
      j++;
    }
    i = j - 1;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
