#include <bits/stdc++.h>
using namespace std;
int n, m, cnt;
map<long long, int> mp;
long long ans;
int main() {
  int i, s, a, b, j, k;
  scanf("%d", &n);
  mp[0] = 1;
  for (i = 1, k = 0; i <= n; i++)
    scanf("%d", &a), k += a, ans += mp[k], mp[k]++;
  printf("%lld", ans);
  return 0;
}
