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