#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, a[200020], sum[200020];
  bool pkd[200020];
  cin >> n;
  for (int i = 0; i < n; i++) {
    sum[i] = 0;
    pkd[i] = true;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = i; j < n; j++) sum[j] += a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (pkd[i]) {
      long long num = sum[i], same = 0;
      for (int j = i; j < n; j++) {
        if (sum[j] == num) {
          same++;
          pkd[j] = false;
        }
      }
      if (same > 1) ans += same * (same - 1) / 2;
      if (num == 0) ans += same;
    }
  }
  cout << ans << endl;
}
