#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> sum(n + 1, 0);
  long long s = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    s += x;
    sum[i] = s;
  }
  sort(sum.begin(), sum.end());
  long long ans = 0;
  for (int i = 0; i < (int)sum.size();) {
    int j = i;
    while (j < sum.size() && sum[i] == sum[j]) ++j;
    ans += (j - i) * (j - i - 1) / 2;
    i = j;
  }
  cout << ans << "\n";
  return 0;
}
