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