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