#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  vector<int> S(N + 1, 0);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    S.at(i + 1) = S.at(i) + A[i];
  }
  sort(S.begin(), S.end());
  int flag = 0;
  long long ans = 0;
  for (int i = 0; i < N + 1; ++i) {
    if (i == N) {
      ans += (long long)(i + 1 - flag) * (i - flag) / 2;
    } else if (S.at(i + 1) != S.at(i)) {
      ans += (long long)(i + 1 - flag) * (i - flag) / 2;
      flag = i + 1;
    }
  }
  cout << ans << endl;
}
