#include <bits/stdc++.h>
using namespace std;
signed main() {
  int N;
  long long ans = 0;
  cin >> N;
  vector<int> v(N);
  for (long long(i) = (0); (i) < (N); (i)++) cin >> v[i];
  for (long long(i) = (1); (i) < (N); (i)++) v[i] += v[i - 1];
  sort((v).begin(), (v).end());
  set<int> s;
  for (auto x : v) s.insert(x);
  for (auto x : s) {
    int n = upper_bound((v).begin(), (v).end(), x) -
            lower_bound((v).begin(), (v).end(), x);
    if (x) {
      ans += n * (n - 1) / 2;
    } else {
      ans += n * (n + 1) / 2;
    }
  }
  cout << ans << endl;
}
