#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> sum(n + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  map<int, int> mp;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}
