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