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