#include <bits/stdc++.h>
using namespace std;
long long n, m, a[500000], b[80000000], c[500000], ans;
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m += a[i];
    c[i] = m + 40000000;
    b[m + 40000000]++;
  }
  for (long long i = 0; i < n; i++) {
    ans += b[c[i]] * (b[c[i]] - 1) / 2;
    b[c[i]] = 0;
  }
  cout << ans;
  return 0;
}
