#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> total(n, 0);
  vector<int> car(n, 0);
  total[0] = a[0];
  car[total[0]]++;
  for (int i = 1; i < n; i++) {
    total[i] = total[i - 1] + a[i];
    car[total[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < car.size(); i++) {
    ans += car[i] * (car[i] - 1) / 2;
  }
  ans += car[0];
  cout << ans << endl;
  return 0;
}
