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