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