#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, sum = 0;
  long S[200000], cnt[200000];
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> S[i];
  for (int i = 0; i < N; i++) {
    sum += S[i];
    if (sum == 0) ans++;
    ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans << endl;
}
