#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long Comb(long long n) { return n * (n - 1) / 2; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> dp(n + 1);
  for (int i = 0; i < n; i++) {
    dp[i + 1] = 0;
  }
  dp[0] = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> dp[i + 1];
    dp[i + 1] += dp[i];
  }
  long long ans = 0;
  sort(dp.begin(), dp.end());
  long long thiscontinue = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (dp[i] == dp[i - 1]) {
      thiscontinue++;
    } else {
      ans += Comb(thiscontinue);
      thiscontinue = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
