#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  map<long long, long long> hoge;
  hoge[0]++;
  long long ruiseki = 0;
  for (auto&& item : a) {
    ruiseki += item;
    hoge[ruiseki]++;
  }
  int res = 0;
  for (auto&& item : hoge) {
    res += item.second * (item.second - 1) / 2;
  }
  cout << res;
}
