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