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