#include <bits/stdc++.h>
using namespace std;
long long A[200000], B[200001];
int main() {
  int N, i;
  long long n = 0;
  cin >> N;
  B[0] = 0;
  for (i = 0; i < N; ++i) {
    cin >> A[i];
    n += A[i];
    B[i + 1] = n;
  }
  sort(B, B + (N + 1));
  n = 0;
  int mi = 0;
  for (i = 1; i < N + 1; ++i) {
    if (B[i - 1] != B[i]) {
      if (i - mi > 1) {
        n += (i - mi) * (i - mi - 1) / 2;
      }
      mi = i;
    }
  }
  if (N + 1 - mi > 1) {
    n += (N + 1 - mi) * (N + 1 - mi - 1) / 2;
  }
  cout << n << endl;
  return 0;
}
