#include <bits/stdc++.h>
using namespace std;
int fact(int n) {
  if (n <= 1)
    return 1;
  else
    return n * fact(n - 1);
}
int comb(int n, int r) {
  if (n == 1) return 0;
  return fact(n) / (fact(r) * fact(n - r));
}
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; ++i) cin >> a[i];
  int s[N];
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += a[i];
    s[i] = sum;
  }
  int ans = 0;
  sort(s, s + N);
  int val = int(pow(10, 10));
  for (int i = 0; i < N; ++i) {
    if (val == s[i]) continue;
    int cnt = 0;
    int j = i;
    val = s[i];
    while (1) {
      if (j == N) break;
      if (s[j] == val)
        cnt += 1;
      else
        break;
      j += 1;
    }
    if (val == 0)
      ans += cnt + comb(cnt, 2);
    else
      ans += comb(cnt, 2);
  }
  cout << ans << endl;
}
