#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long s[N + 1];
  s[0] = 0;
  long long a;
  long long m = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a;
    s[i] = s[i - 1] + a;
    m = (s[i] > m ? s[i] : m);
  }
  map<long long, long long> mp_count;
  for (int i = 0, i_len = (N + 1); i < i_len; ++i) {
    mp_count[s[i]]++;
  }
  long long r = 0;
  for (int i = 0, i_len = (m + 1); i < i_len; ++i) {
    long long c = mp_count[i];
    if (c > 1) {
      r += c * (c - 1) / 2;
    }
  }
  cout << r << "\n";
}
