#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;
  ll 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 I = i;
    for (int j = I; j <= N && A[I] == A[j]; j++) {
      cnt++;
      i++;
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
