#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long(i) = 0; (i) < (n); (i)++) cin >> a[i];
  int sum = 0;
  map<int, int> cnt;
  int ans = 0;
  cnt[0]++;
  for (long long(i) = 0; (i) < (n); (i)++) {
    sum += a[i];
    ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans << endl;
}
