#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n + 1);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  b[0] = 0;
  for (int i = 1; i <= n; ++i) {
    b[i] = b[i - 1] + a[i - 1];
  }
  map<int, int> mp;
  for (int i = 0; i < (n + 1); ++i) mp[b[i]]++;
  ll ans = 0;
  for (auto& p : mp) {
    if (p.second >= 2) {
      ll cnt = p.second * (p.second - 1) / 2;
      ans += cnt;
    }
  }
  cout << ans << endl;
}
