#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N], B[N + 2];
  B[0] = 0LL;
  B[N + 1] = 11111111111111LL;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }
  unsigned long long ans = 0ULL;
  sort(B, B + (N + 1));
  int count = 0;
  long long tmp = 123456;
  for (int i = 0; i <= N + 1; i++) {
    if (tmp != B[i]) {
      ans += (count + 1) * (count) / 2;
      tmp = B[i];
      count = 0;
    } else {
      count++;
    }
  }
  cout << ans << endl;
  return 0;
}
