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