#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> left(n + 1);
  left[0] = 0;
  for (int i = 1; i <= n; i++) left[i] = left[i - 1] + a[i - 1];
  sort(left.begin(), left.end());
  long long ans = 0;
  long long bef = 1000000000009;
  int count = 0;
  for (int i = 0; i <= n; i++) {
    if (bef == left[i])
      count++;
    else {
      ans += ((count * (count - 1)) / 2);
      count = 1;
    }
    bef = left[i];
  }
  ans += ((count * (count - 1)) / 2);
  cout << ans << endl;
}
