#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> A(N + 1);
  map<int, int> mp;
  A[0] = 0;
  mp[0]++;
  long long ans = 0;
  for (int i = (1); i <= (N); ++i) {
    int a;
    cin >> a;
    A[i] = A[i - 1] + a;
    ans += mp[A[i]];
    mp[A[i]]++;
  }
  cout << ans << endl;
  return 0;
}
