#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
int arr[100100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
  }
  int ans = 0;
  mp[0]++;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += arr[i];
    if (mp.count(sum)) ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;
  return 0;
}
