#include <bits/stdc++.h>
using ll = long long;
template <class T, class S>
void cmin(T &a, const S &b) {
  if (a > b) a = b;
}
template <class T, class S>
void cmax(T &a, const S &b) {
  if (a < b) a = b;
}
using namespace std;
signed main() {
  int n;
  string s;
  cin >> n;
  vector<int> dp(n);
  for (int i = 0; i < n; i++) cin >> dp[i];
  vector<int> v = dp;
  for (int i = 0; i < n; i++)
    if (i) dp[i] += dp[i - 1];
  map<int, int> mp;
  for (int i = 0; i < n; i++) mp[dp[i]]++;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) ans = mp[0];
    ans += mp[dp[i]] - 1;
    mp[dp[i]]--;
    ;
  }
  cout << ans << endl;
}
