#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  multiset<long long> st;
  long long sum = 0;
  long long ans = 0;
  if (a[0] == 0) ans++;
  sum = a[0];
  st.insert(0);
  for (long long i = 1; i < n; ++i) {
    st.insert(-sum);
    sum += a[i];
    long long cnt = (long long)st.count(-sum);
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
