#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> accum(N, 0);
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i == 0)
      accum[0] = a[0];
    else
      accum[i] = accum[i - 1] + a[i];
    mp[accum[i]]++;
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->first != 0)
      ans += ((itr->second) * (itr->second - 1)) / 2;
    else
      ans += ((itr->second) * (itr->second + 1)) / 2;
  }
  cout << ans << endl;
}
