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