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