#include <iostream>
#include <map>
using namespace std;

int main(){
  int n;
  long long a, sum = 0, counter = 0;
  map<long long, int> mp;
  cin >> n;
  mp[sum] = 1;
  for(int i=1; i<=n; i++){
    cin >> a;
    sum += a;
    counter += mp[sum];
    mp[sum]++;
  }
  cout << counter << endl;
}