#include <bits/stdc++.h>
const int MAX = 1e5 + 10;
using namespace std;
int main() {
  long long N, ans = 0, cnt = 0;
  cin >> N;
  long long A[N];
  set<int> s;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    if (i != 0) A[i] += A[i - 1];
  }
  sort(A, A + N);
  for (int i = 0; i < N; i++) {
    if (!s.count(A[i])) {
      if (cnt != 0) ans += cnt * (cnt - 1) / 2;
      s.insert(A[i]);
      cnt = 1;
    } else
      cnt++;
    if (A[i] == 0) ans++;
    if (i == N - 1) ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
