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