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