#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, count = 0, sum = 0;
  map<int, int> mp;
  cin >> N;
  mp[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> A;
    count += A;
    mp[count]++;
  }
  map<int, int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    int x = it->second;
    sum += x * (x - 1) / 2;
  }
  cout << sum << endl;
}
