#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, n, m = 1, counter = 0;
  map<int, int> mp;
  cin >> n;
  int sum[n + 1];
  sum[0] = 0;
  mp[sum[0]] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    sum[i] = sum[i - 1] + a;
    mp[sum[i]] += 1;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    counter += (itr->second * (itr->second - 1)) / 2;
  }
  cout << counter << endl;
}
