#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll s = 0;
  map<ll, ll> res;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s += a;
    ans += res[s];
    res[s]++;
  }
  cout << ans << endl;
}
