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