#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> s(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    cin >> a.at(i);
    s.at(i + 1) = s.at(i) + a.at(i);
  }
  int ans = 0;
  sort(s.begin(), s.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == s.at(i + 1))
      cnt++;
    else if (cnt != 0) {
      ans += ((cnt + 1) * cnt) / 2;
      cnt = 0;
    }
  }
  ans += ((cnt + 1) * cnt) / 2;
  cout << ans << endl;
}
