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