#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a[200010], ans[200010];
  cin >> n;
  ans[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans[i + 1] = ans[i] + a[i];
  }
  sort(ans, ans + n + 1);
  int cnt = 0;
  int start = ans[0], l = 0;
  for (int i = 0; i < n + 1; i++) {
    if (ans[i] != start) {
      start = ans[i];
      cnt += l * (l - 1) / 2;
      l = 0;
    }
    l++;
    if (i == n) {
      cnt += l * (l - 1) / 2;
    }
  }
  cout << cnt << '\n';
  return 0;
}
