#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n + 1);
  b.at(0) = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
    b.at(i + 1) = a.at(i) + b.at(i);
  }
  int ans = 0;
  sort(b.begin(), b.end());
  int i = 0;
  while (i < n + 1) {
    int c = count(b.begin(), b.end(), b.at(i));
    ans += c * (c - 1) / 2;
    i += c;
  }
  cout << ans << endl;
}
