#include <bits/stdc++.h>
using namespace std;
constexpr double PI = 3.14159265358979323846;
constexpr long long INF = 1 << 29;
constexpr long long MOD = (long long)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};
struct edge {
  long long to;
  long long cost;
};
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = (int)(0); i < (int)(N); i++) cin >> A[i];
  vector<long long> a(N + 1, 0);
  for (int i = (int)(0); i < (int)(N); i++) a[i + 1] = A[i];
  for (int i = (int)(0); i < (int)(N); i++) a[i + 1] += a[i];
  int ans = 0;
  for (int i = (int)(1); i < (int)(N + 1); i++)
    if (a[i] == 0) ans++;
  for (int i = (int)(1); i < (int)(N + 1); i++) {
    for (int j = (int)(i + 1); j < (int)(N + 1); j++) {
      if (a[j] - a[i] == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
