#include <bits/stdc++.h>
const int INF = 1e9 + 7;
using namespace std;
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> b(n + 1);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  b[0] = a[0];
  for (int i = (1); i < (n); ++i) b[i] = b[i - 1] + a[i];
  b[n] = 0;
  sort(b.begin(), b.end());
  long long ans = 0;
  int kpa = b[0], cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (kpa == b[i])
      ++cnt;
    else {
      ans += (cnt + 1) * cnt / 2;
      kpa = b[i];
      cnt = 0;
    }
  }
  ans += (cnt + 1) * cnt / 2;
  cout << ans << endl;
  return 0;
}
