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