#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  long long A[200000 + 1], B[200000 + 1];
  B[0] = 0;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 1; i < N + 1; i++) B[i] = A[i - 1] + B[i - 1];
  sort(B, B + N + 1);
  int ans = 0, same_number_count = 1;
  for (int i = 0; i < N + 1; i++) {
    if (B[i] == B[i + 1])
      same_number_count += 1;
    else if (B[i] != B[i + 1] || i == N - 2) {
      ans += same_number_count * (same_number_count - 1) / 2;
      same_number_count = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
