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