#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)n; i++) cin >> a[i];
  multiset<long long> s;
  long long sum = 0;
  long long ans = 0;
  s.insert(0);
  for (long long i = 0; i < (long long)n; i++) {
    sum += a[i];
    s.insert(sum);
    ans += s.count(sum);
  }
  cout << ans - n << endl;
}
