#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  int ans = 0;
  vector<long long> sum(n);
  map<long long, int> m;
  for (int i = 0; i < (int)(n); ++i) {
    if (i == 0)
      sum[0] = a[0];
    else
      sum[i] = sum[i - 1] + a[i];
    m[sum[i]]++;
    if (sum[i] == 0) ans++;
    ans += m[sum[i]] - 1;
  }
  cout << ans << endl;
}
