#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a.at(i);
  vector<int64_t> sm(n + 1, 0);
  for (int i = 0; i < (int)(n); i++) sm.at(i + 1) = sm.at(i) + a.at(i);
  map<int64_t, int64_t> mp;
  for (int i = 0; i < (int)(n + 1); i++) mp[sm.at(i)] += 1;
  int sum = 0;
  for (auto i : mp) {
    int tmp = i.second;
    sum += (tmp - 1) * tmp / 2;
  }
  cout << sum << endl;
}
