#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> m;
  int in, sum = 0;
  int ans = 0;
  m[0] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> in;
    sum += in;
    ans += m[sum]++;
  }
  cout << ans << endl;
}
