#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    ll t;
    cin >> t;
    dp[i + 1] = dp[i] + t;
  }
  ll cnt = 0;
  ll maxv = *max_element((dp).begin(), (dp).end());
  vector<ll> his(maxv + 1, 0);
  for (int i = (n + 1 - 1); i >= 0; --i) {
    cnt += his[dp[i]];
    his[dp[i]]++;
  }
  cout << cnt << endl;
  return 0;
}
