#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> acc(n + 1, 0);
  priority_queue<long long> pq;
  pq.push(0);
  for (int i = 0; i < n; i++) {
    acc[i + 1] = acc[i] + a[i];
    pq.push(acc[i + 1]);
  }
  long long now = pq.top();
  pq.pop();
  int cnt = 1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (now == pq.top())
      cnt++;
    else {
      if (cnt > 1) ans += cnt * (cnt - 1) / 2;
      now = pq.top();
      cnt = 1;
    }
    pq.pop();
  }
  if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
}
