#include <bits/stdc++.h>
using namespace std;
int a[200001];
int dp[200001] = {};
int main(void) {
  int n;
  long long int count = 0;
  int point = 0;
  cin >> n;
  for (long long int i = (0); i <= (n - 1); i++) {
    cin >> a[i];
    if (i == 0) {
      dp[i] = a[i];
    } else {
      dp[i] += dp[i - 1] + a[i];
    }
  }
  sort(dp, dp + n);
  for (long long int i = (0); i <= (n - 2); i++) {
    if (dp[i] == 0) {
      count++;
    }
    if (dp[i] == dp[i + 1]) {
      point++;
    } else {
      count += (point) * (point + 1) / 2;
      point = 0;
    }
    if (i == n - 1) {
      count += (point) * (point + 1) / 2;
      point = 0;
    }
  }
  cout << count << endl;
  return 0;
}
