#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 200000;
int N, A;
map<int, long long int> mpa;
int main() {
  cin >> N;
  long long int sum = 0;
  mpa[sum]++;
  for (int i = 0; i < N; i++) {
    cin >> A;
    sum += A;
    mpa[sum]++;
  }
  long long int ans = 0;
  for (auto e : mpa) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
