#include <bits/stdc++.h>
using namespace std;
signed main() {
  int N;
  long long ans = 0;
  cin >> N;
  vector<long long> v(N + 1);
  v[0] = 0;
  for (long long(i) = (0); (i) < (N); (i)++) cin >> v[i + 1];
  for (long long(i) = (1); (i) < (N + 1); (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) {
    long long n = upper_bound((v).begin(), (v).end(), x) -
                  lower_bound((v).begin(), (v).end(), x);
    ans += n * (n - 1) / 2;
  }
  cerr << "v" << ':';
  for (auto x : v) cerr << x << ' ';
  cerr << endl;
  ;
  cout << ans << endl;
}
