#include <bits/stdc++.h>
using namespace std;
long long N;
long long s[200200];
multiset<long long> x, y;
long long A[200200];
signed main() {
  cin >> N;
  for (long long i = 0; i < (N); ++i) {
    cin >> A[i];
    s[i + 1] = s[i] + A[i];
    x.insert(s[i + 1]);
  }
  long long ans = 0;
  for (long long i = 0; i < (N); ++i) {
    ans = ans + x.count(s[i]) - y.count(s[i]);
    y.insert(s[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
