#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, a, ac;
ll ans;
map<ll, int> mp;
int main() {
  scanf("%d", &n);
  mp[0]++;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &a);
    mp[ac += a]++;
  }
  for (auto it : mp) {
    int t = it.second;
    ans += (ll)t * (t - 1) / 2;
  }
  printf("%lld\n", ans);
}
