#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);
  }
  sort(b.begin(), b.end());
  int ans = 0;
  int c = 1;
  for (int i = 0; i < n; ++i) {
    bool f = 1;
    for (int j = i + 1; j < n + 1 && f; ++j) {
      if (b.at(i) == b.at(j))
        ++c;
      else
        f = 0;
    }
    i += c - 1;
    ans += c * (c - 1) / 2;
    c = 1;
  }
  cout << ans << endl;
}
