#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], b;
  cin >> a[0];
  int ans[n];
  ans[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> b;
    a[i] = a[i - 1] + b;
    ans[i] = 0;
  }
  if (a[0] == 0) {
    ans[0]++;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == 0) {
      ans[i]++;
    }
    for (int j = i - 1; j >= 0; j -= 1) {
      if (a[i] - a[j] == 0) {
        if (j != 0) {
          ans[i] += ans[j] + 1;
          if (a[j] == 0) {
            ans[i]--;
          }
        } else {
          ans[i] += 1;
        }
        break;
      }
    }
  }
  int nans = 0;
  for (int i = 0; i < n; i++) {
    nans += ans[i];
  }
  cout << nans << endl;
  return (0);
}
