#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  ;
  vi A(N);
  vl sum(N + 1, 0);
  for (int i = (0); i < (N); ++i) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
  }
  int ans = 0;
  map<ll, int> m;
  for (int i = N; i >= 0; --i) {
    ans += m[sum[i]];
    ++m[sum[i]];
  }
  cout << ans << "\n";
  return 0;
}
