#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> as(n + 1);
  for (int i = int(0); i < int(n); i++) {
    int first;
    cin >> first;
    as[i + 1] = as[i] + first;
  }
  unordered_map<ll, int> mp;
  for (int c : as) mp[c]++;
  ll cnt = 0;
  for (auto& p : mp) {
    ll c = p.second;
    cnt += c * (c - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
