#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
const int MAX_A = 1e9;
int N;
int a[MAX_N];
long long int comb2(int n) {
  if (n < 2) {
    return 0;
  }
  return 1LL * n * (n - 1LL) / 2LL;
}
long long int solve() {
  long long int s[MAX_N + 2];
  s[0] = 0;
  for (int i = 0; i < N; i++) {
    s[i + 1] = s[i] + a[i];
  }
  s[N + 1] = MAX_A + 1;
  sort(s, s + N + 2);
  long long int ans = 0;
  int prev_i = 0;
  long long int prev_s = s[0];
  for (int i = 1; i <= N + 1; i++) {
    if (s[i] != prev_s) {
      ans += comb2(i - prev_i);
      prev_i = i;
      prev_s = s[i];
    }
  }
  return ans;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  cout << solve() << endl;
  return 0;
}
