#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long int LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
signed main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  long long int b[n + 1], sum = 0;
  b[0] = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum += a[i];
    b[i + 1] = sum;
  }
  sort(b, b + n + 1);
  int cnt = 1, ans = 0;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (b[i] == b[i + 1])
      cnt++;
    else if (cnt > 1)
      ans += cnt * (cnt - 1) / 2, cnt = 1;
  }
  for (int i = 0; i < (int)(n + 1); i++) cerr << b[i] << ' ';
  cerr << endl;
  cout << ans << endl;
  return 0;
}
