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