#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
template <class A, class B>
inline bool chmax(A &a, const B &b) {
  return b > a && (a = b, true);
}
template <class A, class B>
inline bool chmin(A &a, const B &b) {
  return b < a && (a = b, true);
}
template <class T>
using MAX_pq = priority_queue<T>;
template <class T>
using MIN_pq = priority_queue<T, vector<T>, greater<T>>;
template <class A>
inline long long abs(A &a) {
  return (a < 0 ? -a : a);
}
const long long Mod = (1e9) + 7;
const long long mod = 998244353;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
long long n, m, k, r, q;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> s(n + 1);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + a[i - 1];
  }
  map<long long, int> make_pair;
  for (int i = 0; i <= n; i++) {
    make_pair[s[i]]++;
  }
  long long ans = 0;
  set<long long> st;
  for (int i = 0; i <= n; i++) {
    if (st.find(s[i]) == st.end()) {
      ans += make_pair[s[i]] * (make_pair[s[i]] - 1);
      st.insert(s[i]);
    }
  }
  cout << ans / 2 << '\n';
  return (0);
}
