#include <bits/stdc++.h>
using namespace std;
long long int dp[200000][2];
long long int nCr(long long int n, long long int r) {
  if (n < r) return 0;
  if (n == r) return dp[n][r] = 1;
  if (r == 0) return dp[n][r] = 1;
  if (r == 1) return dp[n][r] = n;
  if (dp[n][r]) return dp[n][r];
  return dp[n][r] = nCr(n - 1, r) + nCr(n - 1, r - 1);
}
int main() {
  long long int ans = 0;
  long long int N;
  cin >> N;
  vector<long long int> cumsum(N);
  for (long long int i = 0; i < (long long int)(N); i++) {
    cin >> cumsum[i];
    if (i == 0) {
      continue;
    }
    cumsum[i] += cumsum[i - 1];
  }
  sort((cumsum).begin(), (cumsum).end());
  long long int judge = 1000000001;
  long long int keep = 1;
  for (long long int i = 1; i < (long long int)(N); i++) {
    if (cumsum[i] == cumsum[i - 1]) {
      keep++;
      if (i == N - 1) {
        if (cumsum[i] == 0) {
          ans += nCr(keep, 2) + keep;
        } else
          ans += nCr(keep, 2);
      }
    } else {
      if (cumsum[i - 1] == 0) {
        ans += nCr(keep, 2) + keep;
        keep = 1;
      } else {
        ans += nCr(keep, 2);
        keep = 1;
      }
    }
  }
  cout << ans << endl;
}
