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