#include <bits/stdc++.h>
using namespace std;
int ans, sum, a[300000], b[300000], n;
map<int, int> m;
signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
  for (int i = 0; i < n - 1; i++) b[i + 1] += b[i];
  for (int i = 0; i < n; i++) m[b[i]]++;
  for (int i = 0; i < n; i++) {
    ans += m[sum];
    m[b[i]]--;
    sum += a[i];
  }
  cout << ans << endl;
}
