#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int ans = 0;
  cin >> n;
  int array[n];
  for (int i = 0; i < n; i++) cin >> array[i];
  for (int i = 0; i < n; i++) {
    long long temp = 0;
    int judge = 0;
    if (array[i] < 0) judge = 1;
    for (int j = i + 1; j < n; j++) {
      temp += array[j];
      if (array[i] + temp == 0) ans++;
      if (judge == 0)
        if (array[i] + temp < 0) break;
      if (judge == 0)
        if (array[i] + temp > 0) break;
    }
  }
  cout << ans << endl;
  return 0;
}
