#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  vector<int> A(N);
  int s = 0;
  map<long, int> mp;
  mp[s]++;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    s += A[i];
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << endl;
  return 0;
}
