#include <bits/stdc++.h>
using namespace std;
long long ans;
map<long long, long long> m;
signed main() {
  long long n;
  cin >> n;
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
  for (long long i = 0; i < n - 1; i++) b[i + 1] += b[i];
  for (long long i = 0; i < n; i++) m[b[i]]++;
  for (long long i = 0; i < n; i++) {
    ans += m[0];
    m[b[i]]--;
  }
  cout << ans << endl;
}
