#include <bits/stdc++.h>
using namespace std;
const int MAX = 200000;
int main() {
  static int N, A[MAX];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  static int sum[MAX + 1];
  sum[0] = 0;
  for (int i = 0; i < N; i++) sum[i + 1] = A[i] + sum[i];
  sort(sum, sum + N + 1);
  int64_t ans = 0;
  int num = 1;
  for (int i = 1; i <= N; i++) {
    if (sum[i] == sum[i - 1])
      num++;
    else {
      ans += (int64_t)num * (num - 1) / 2;
      num = 1;
    }
  }
  ans += (int64_t)num * (num - 1) / 2;
  cout << ans;
  return 0;
}
