#include <bits/stdc++.h>
using namespace std;
int calc(int a) { return a * (a - 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  vector<int64_t> a(n + 1);
  int ans = 0;
  unordered_map<uint64_t, int> cnt;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a[i + 1] = a[i] + t;
    ans += cnt[a[i + 1]];
    cnt[a[i]]++;
  }
  cout << ans << "\n";
}
