#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long S[N + 1];
  S[0] = 0;
  for (int i = 0; i < N; i++) S[i + 1] = S[i] + A[i];
  map<long, int> mp;
  for (int i = 0; i <= N; i++) {
    if (mp.find(S[i]) == mp.end())
      mp[S[i]] = 1;
    else
      mp[S[i]] = mp[S[i]] + 1;
  }
  int ans = 0;
  for (auto m : mp) ans += m.second * (m.second - 1) / 2;
  cout << ans << endl;
  return 0;
}
