#include <bits/stdc++.h>
using namespace std;
long long Power(long long a, long long x) {
  int num = a;
  for (long long i = (1); i < (x); i++) num *= a;
  return num;
}
long long Factorial(long long num) {
  int ret = 1;
  for (long long i = (2); i < (num + 1); i++) ret *= i;
  return ret;
}
long long Func(long long num) {
  int ret = 0;
  for (long long i = (1); i < (num + 1); i++) ret += i;
  return ret;
}
long long N, ans;
string S;
long long A[200001];
int main() {
  cin >> N;
  cin >> A[0];
  for (long long i = (1); i < (N); i++) {
    cin >> A[i];
    A[i] += A[i - 1];
  }
  A[N] = 0;
  sort(A, A + N + 1);
  int count = 0;
  for (long long i = (1); i < (N + 1); i++) {
    if (A[i] == A[i - 1])
      count++;
    else {
      if (count != 0) ans += Func(count);
      count = 0;
    }
  }
  if (count != 0) ans += Func(count);
  cout << ans << endl;
  cin >> ans;
  return 0;
}
