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