#include <bits/stdc++.h>
using namespace std;
long long n, ans, sum;
map<long long, long long> mp;
long long read(long long ret = 0) { return scanf("%d", &ret), ret; }
int main() {
  for (n = read(), mp[0] = 1; n--; ans += mp[sum += read()]++)
    ;
  return printf("%lld\n", ans), 0;
}
