#include <bits/stdc++.h>
using namespace std;
long long c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i + 1][j] += c[i][j];
      c[i + 1][j + 1] += c[i][j];
    }
  }
}
long long comb(int n, int k) { return c[n][k]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init();
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < (n); ++i) cin >> A[i];
  vector<int> b(n + 1);
  b[0] = 0;
  for (int i = 1; i <= n; ++i) {
    b[i] = b[i - 1] + A[i - 1];
  }
  int ans = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (b[i] == 0) ans++;
  }
  sort((b).begin(), (b).end());
  int k = 0;
  for (int i = 2; i <= n; ++i) {
    if (b[i - 1] != b[i]) {
      k++;
      if (k >= 2) {
        ans += c[k][2];
      }
      k = 0;
    } else
      k++;
  }
  k++;
  if (k >= 2) ans += c[k][2];
  cout << (ans) << endl;
  return 0;
}
