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