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