#include <bits/stdc++.h>
using namespace std;
int N;
long long A[300000];
int main(int argc, const char* argv[]) {
  cin >> N;
  for (int n = 0; n < N; ++n) {
    cin >> A[n];
  }
  vector<long long> v;
  long long tmp = 0;
  for (int n = 0; n < N; ++n) {
    tmp += A[n];
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  tmp = 0;
  long long res = 0;
  vector<long long> v2;
  for (int i = 0; i < N; ++i) {
    if (v[i] == tmp) {
      res++;
    } else {
      if (res != 0) {
        v2.push_back(res);
        res = 0;
      }
      tmp = v[i];
    }
  }
  if (res != 0) v2.push_back(res);
  res = 0;
  for (int i = 0; i < v2.size(); ++i) {
    res += (v2[i] * (v2[i] + 1)) / 2;
  }
  cout << res << endl;
  return 0;
}
