#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), s(n + 1);
  s[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  long long ans = 0;
  sort(s.begin(), s.end());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == s[i + 1]) {
      ++cnt;
      ans += cnt;
    } else
      cnt = 0;
  }
  cout << ans << endl;
  return 0;
}
