#include <bits/stdc++.h>
using namespace std;
uint64_t MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int n = 0; n < N; n++) cin >> A.at(n);
  map<int64_t, int> mp;
  mp[0]++;
  int64_t sumA = 0;
  for (int n = 0; n < N; n++) {
    sumA += A.at(n);
    mp[sumA]++;
  }
  int64_t ans = 0;
  for (auto m : mp) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;
}
