#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[100010];
  long long s[100010];
  long long tmp = 0;
  map<long long, long long> mp;
  mp[0]++;
  s[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
    mp[s[i]]++;
  }
  long long ans = 0;
  set<long long> st;
  for (int i = 0; i < n; i++) {
    st.insert(s[i]);
  }
  for (auto itr = st.begin(); itr != st.end(); itr++) {
    tmp = mp[*itr];
    if (tmp > 1) ans += tmp * (tmp - 1) / 2;
  }
  cout << ans;
}
