#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using Graph = vector<vector<int>>;
const long long max_n = 200000;
long long a[max_n], s[max_n + 1];
long long n, ans = 0;
void solve() {
  fill(s, s + n + 1, 0);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < n; i++) {
    long long m = i;
    while (m < n) {
      m = lower_bound(s + m, s + n, s[i]) - s;
      if (s[m] - s[i] == 0 && m != i)
        ans++;
      else if (m == i)
        m++;
    }
  }
  cout << ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve();
}
