#include <bits/stdc++.h>
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), sum(n + 1, 0);
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  ll ans = 0;
  sort(sum.begin(), sum.end());
  for (int i = (int)0; i < (int)n; ++i) {
    int j = 1;
    ll cnt = 0;
    ;
    while (i + j <= n && sum[i] == sum[i + j]) {
      ++cnt;
      ++j;
    }
    --j;
    i += j;
    ans += cnt * (cnt + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
