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