#include <bits/stdc++.h>
using namespace std;
long long int n, a[200010], q = 1, g, xx, sm = 0, b[200010];
vector<long long int> s;
vector<long long int> akrk(long long int target[], long long int size) {
  vector<long long int> result;
  int repeats = 1, number = target[0];
  for (int i = 1; i < size; i++) {
    if (number == target[i])
      repeats++;
    else {
      number = target[i];
      result.push_back(repeats);
      repeats = 1;
    }
  }
  result.push_back(repeats);
  return result;
}
int main() {
  scanf("%lld", &n);
  b[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    b[i + 1] = b[i] + a[i];
  }
  sort(b, b + n + 1);
  g = b[0];
  s = akrk(b, n + 1);
  for (int itr : s) {
    sm += itr * (itr - 1) / 2;
  }
  printf("%lld\n", sm);
}
