#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  map<long long int, long long int> mp;
  long long int sum = 0;
  long long int cnt = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    cnt += mp[sum];
    if (sum == 0) cnt++;
    mp[sum]++;
  }
  cout << cnt;
  return 0;
}
