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