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