#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), S(N + 1);
  for (int i = 0; i < N; i++) cin >> A[i];
  S[0] = 0;
  for (int i = 0; i < N; i++) S[i + 1] = S[i] + A[i];
  sort(S.begin(), S.end());
  long long cnt = 1;
  long long ans = 0;
  for (int i = 1; i < N + 1; i++) {
    if (S[i - 1] != S[i]) {
      if (cnt > 1) {
        ans += cnt * (cnt - 1) / 2;
        cout << cnt * (cnt - 1) / 2 << endl;
      }
      cnt = 1;
    } else
      cnt++;
  }
  if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
}
