#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long a[N + 1];
  a[0] = 0;
  for (int i = 1; i <= N; i++) {
    int b;
    cin >> b;
    a[i] = a[i - 1] + b;
  }
  sort(a, a + N + 1);
  int ans = 0;
  long long temp = a[0];
  int temp_count = 1;
  for (int i = 1; i <= N; i++) {
    if (temp == a[i]) {
      ans += temp_count;
      temp_count++;
    } else {
      temp = a[i];
      temp_count = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
