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