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