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