#include <bits/stdc++.h>
using namespace std;
int N;
long long A[2 * 112345];
long long sum[2 * 112345];
map<long long, int> mp;
int ans;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum[i] += A[i];
    mp[sum[i]]++;
    sum[i + 1] = sum[i];
  }
  if (mp.find(0) != mp.end()) ans += mp[0];
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int n = itr->second;
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
