#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a;
  cin >> n;
  vector<int> q;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push_back(a);
  }
  int ans = 0;
  vector<int> e;
  e.push_back(0);
  for (int i = 0; i < n; i++) {
    e.push_back(e[i] + q[i]);
  }
  for (int i = 0; i < e.size(); i++) {
    mp[e[i]]++;
  }
  for (auto e : mp) {
    ans += (e.second * (e.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
