#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 100;
long long n, pref[MAXN], ct[MAXN];
int main() {
  cin >> n;
  long long ai;
  for (int i = 1; i <= n; ++i) {
    cin >> ai;
    pref[i] = pref[i - 1] + ai;
  }
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    ct[pref[i]]++;
    ans += ct[pref[i]] - 1;
  }
  cout << ans;
  return 0;
}
