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