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