#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a, s[100005];
  map<long, long> mp;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    s[i] = s[i - 1] + a;
  }
  for (int i = 0; i <= n; i++) ++mp[s[i]];
  long long ans = 0;
  for (auto t : mp) {
    ans += (t.second * (t.second - 1)) / 2;
  }
  cout << ans << endl;
}
