#include <bits/stdc++.h>
using namespace std;
int arr[200001], psum[200001], N;
map<int, int> m;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> arr[i];
  }
  int res = 0;
  m[0] = 1;
  for (int i = 1; i <= N; ++i) {
    psum[i] = psum[i - 1] + arr[i];
    res += m[psum[i]];
    m[psum[i]]++;
  }
  cout << res;
}
