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