#include <bits/stdc++.h>
using namespace std;
int A[100005];
long long psum[100005];
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  set<long long> st;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    psum[i] = psum[i - 1] + 1LL * A[i];
    st.insert(psum[i]);
  }
  sort(psum + 1, psum + 1 + n);
  for (auto it = st.begin(); it != st.end(); it++) {
    long long val = *it;
    int cnt = upper_bound(psum + 1, psum + 1 + n, val) -
              lower_bound(psum + 1, psum + 1 + n, val);
    ans += 1LL * cnt * (cnt - 1) / 2;
  }
  for (int i = 1; i <= n; i++)
    if (psum[i] == 0) ans++;
  cout << ans;
}
