#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, x = 1, ans = 0, j = 0;
  cin >> n;
  vector<long long>(a)((n));
  vector<long long>(s)((n));
  cin >> a[0];
  s[0] = a[0];
  for (long long i = (1); i < (n); ++i) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  sort(s.begin(), s.end());
  for (long long j = 0; j < (n); ++j) {
    if (s[j] == 0) {
      ans++;
    } else if (s[j] > 0) {
      break;
    }
  }
  for (long long i = 0; i < (n); ++i) {
    if (s[i] == s[i + 1]) {
      x += 1;
    } else {
      ans = ans + x * (x - 1) / 2;
      x = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
