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