#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n), s(n + 1);
  for (int i = 0; i < (int)n; i++) cin >> a[i];
  s[0] = 0;
  for (int i = 0; i < (int)n; i++) {
    s[i + 1] = s[i] + a[i];
  }
  sort((s).begin(), (s).end());
  map<int, int> mp;
  for (int i = 0; i < (int)n + 1; i++) {
    mp[s[i]]++;
  }
  for (auto e : mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
