#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> s(n + 1);
  ll sum = 0;
  s[0] = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    ll a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  sort(s.begin(), s.end());
  int ans = 0;
  int c = 1;
  for (int(i) = 0; (i) < (n); (i)++) {
    if (s[i] == s[i + 1])
      c++;
    else {
      ans += c * (c - 1) / 2;
      c = 1;
    }
  }
  cout << ans + c * (c - 1) / 2 << endl;
  return 0;
}
