#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;
}
int cache[100010][3];
int ncr(int n, int r) {
  if (cache[n][r] == -1) cache[n][r] = ncr(n - 1, r) + ncr(n - 1, r - 1);
  return cache[n][r];
}
int get_ncr(int n, int r) {
  int i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      cache[i][j] = -1;
    }
  }
  for (i = 1; i <= n; i++) {
    cache[i][0] = 1;
    cache[i][i] = 1;
  }
  return ncr(n, r);
}
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 += get_ncr(itr, 2);
  }
  printf("%lld\n", r);
}
