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