#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int maxn = 100100;
int n;
long long s, res;
map<long long, int> mp;
void solve() {
  scanf("%d", &n);
  mp[0ll] = 1;
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    s += x;
    res += mp[s];
    mp[s]++;
  }
  printf("%I64d", res);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
