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