#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  long long a[210000];
  long long sum = 0;
  int b;
  for (int i = 0; i < N; i++) {
    cin >> b;
    sum += b;
    a[i] = sum;
  }
  a[N] = 0;
  a[N + 1] = INT_MAX;
  sort(a, a + N + 2);
  long long cnt = 1;
  long long ans = 0;
  for (int i = 1; i <= N + 1; i++) {
    if (a[i - 1] == a[i])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans;
}
