#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long long INF = (long long)1e18 * 5;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < (N); i++) cin >> A[i];
  map<long long, long long> m;
  m[A[0]] = 1;
  for (long long i = 0; i < (N - 1); i++) {
    A[i + 1] += A[i];
    if (m.find(A[i + 1]) == m.end())
      m[A[i + 1]] = 1;
    else
      m[A[i + 1]]++;
  }
  long long ans = 0;
  for (auto i : m) {
    if (i.first == 0) {
      long long tmp = 1, x = 1;
      while (i.second != x - 1) {
        tmp *= x;
        x++;
      }
      ans += tmp;
    } else
      ans += (i.second) * (i.second - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
