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