#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
LL h, w, n, m, k, s, t, q, last, cnt, ans, a[400000];
pair<LL, LL> sum[400000];
string str, ss;
bool f;
char c;
int di[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
struct Edge {
  LL to, cost;
};
vector<Edge> vec[10000];
set<LL> st;
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  cin >> n;
  for (LL i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1].first += sum[i].first + a[i];
    sum[i + 1].second = i + 1;
  }
  sort(sum, sum + n + 1);
  for (LL i = 0; i < n + 1; i++) {
    auto it =
        lower_bound(sum, sum + n, pair<LL, LL>(sum[i].first, 0),
                    [](pair<LL, LL> x, pair<LL, LL> y) {
                      return x.first < y.first ||
                             (x.first == y.first ? x.second < y.second : 0);
                    }) -
        sum;
    while (sum[i].first == sum[it].first && sum[it].second < sum[i].second)
      ans++, it++;
  }
  cout << ans << endl;
  return 0;
}
