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