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