#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  int k = a % b;
  if (k == 1) return 1;
  if (k == 0) return b;
  int ans = gcd(b, k);
  return ans;
}
int digisum(long long a) {
  int sum = 0;
  while (a) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}
int a[200010];
vector<long long> v;
int n;
int main() {
  cin >> n;
  v.push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(v[i] + a[i]);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  int last = 1;
  for (int i = 1; i < v.size(); i++) {
    if (v[i] == v[i - 1])
      last++;
    else {
      ans += (last - 1) * last / 2;
      last = 1;
    }
  }
  ans += (last - 1) * last / 2;
  cout << ans << endl;
}
