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