#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long a[200005];
  vector<long long> sum;
  sum.push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum.push_back(sum[i] + a[i]);
  }
  sort(sum.begin(), sum.end());
  long long flag = 0;
  long long cnt = 0;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    if (sum[i] == sum[i + 1]) {
      flag++;
      cnt += flag;
    } else {
      flag = 0;
      ans += cnt;
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
