#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A;
  cin >> N;
  long long ans = 0, nsum = 0;
  map<int, int> dic;
  dic[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> A;
    nsum += A;
    ans += dic[nsum];
    dic[nsum] += 1;
  }
  cout << ans << endl;
  return 0;
}
