#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long now = 0LL;
  map<long long, int> m;
  m[0]++;
  for (int i = 0; i < (int)(n); i++) {
    long long tmp;
    cin >> tmp;
    now += tmp;
    m[now]++;
  }
  long long ans = 0LL;
  for (auto w : m) {
    ans += w.second * (w.second - 1) / 2LL;
  }
  cout << ans << endl;
  return 0;
}
