#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long N, ans = 0;
long long str[200001];
int main(void) {
  cin >> N;
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    if (i != 0)
      str[i] = str[i - 1] + a;
    else
      str[i] = a;
  }
  sort(str, str + N);
  int cnt = 0;
  for (long long i = 1; i < N; i++) {
    if (str[i - 1] == str[i]) {
      cnt++;
    } else {
      if (cnt > 0) {
        cnt++;
        ans += cnt * (cnt - 1) / 2;
      }
      cnt = 0;
    }
    if (str[i] == 0) ans++;
  }
  if (str[0] == 0) ans++;
  if (cnt > 0) {
    cnt++;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
