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