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