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