#include <bits/stdc++.h>
using namespace std;
bool comp(long long a, long long b) { return abs(a) < abs(b); }
int main() {
  long long ans = 0;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    a[i] += a[i - 1];
  }
  for (int i = 0; i < n; i++)
    if (a[i] == 0) ans++;
  sort(a.begin(), a.end(), comp);
  long long now = 0;
  long long count = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == now)
      count++;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
      now = a[i];
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}
