#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
long long d[200005];
long long sum = 0, cnt = 0;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) d[i] = d[i - 1] + a[i - 1];
  sort(d, d + n + 1);
  cnt = 1;
  for (int i = 1; i <= n; i++) {
    if (d[i] == d[i - 1])
      cnt++;
    else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  v.push_back(cnt);
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] % 2 == 0)
      ans += v[i] / 2 * (v[i] - 1);
    else
      ans += (v[i] - 1) / 2 * v[i];
  }
  cout << ans;
  return 0;
}
