#include <bits/stdc++.h>
const int INF = (int)1e9;
const long long MOD = (long long)1e9 + 7;
const long long LINF = (long long)4e18 + 20;
const long double PI = acos(-1.0);
const double EPS = 1e-9;
using namespace ::std;
void solve() {
  int N;
  cin >> N;
  vector<long long> rui(N);
  for (int i = 0; i < N; ++i) {
    cin >> rui[i];
    if (i) {
      rui[i] += rui[i - 1];
    }
  }
  sort(rui.begin(), rui.end());
  long long ans = 0;
  long long prev = 0;
  long long count = 0;
  for (int i = 0; i < N; ++i) {
    if (prev == rui[i]) {
      ++count;
    } else {
      prev = rui[i];
      count = 0;
    }
    ans += count;
  }
  cout << ans << endl;
}
signed main(void) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed;
  cout << setprecision(16);
  solve();
}
