#include <bits/stdc++.h>
using namespace std;
int n;
long long int a[100010], r = 0;
vector<long long int> z = {0}, q;
vector<long long int> krk(vector<long long int> target) {
  vector<long long int> result;
  long long int repeats = 1, number = target[0];
  for (long long int i = 1; i < target.size(); i++) {
    if (number == target[i])
      repeats++;
    else {
      number = target[i];
      result.push_back(repeats);
      repeats = 1;
    }
  }
  result.push_back(repeats);
  return result;
}
long long int combi(long long int n, long long int k) {
  if (n < k) return 0;
  if (n == k or k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    z.push_back(z[i] + a[i]);
  }
  sort(z.begin(), z.end());
  q = krk(z);
  for (long long int itr : q) {
    r += combi(itr, 2);
  }
  printf("%lld\n", r);
}
