#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
  int n;
  ll a;
  cin >> n;
  vector<ll> arr(n + 1, 0);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a;
    arr[i + 1] = arr[i] + a;
  }
  map<int, int> m;
  for (auto s : arr) m[s]++;
  int ans = 0;
  for (auto mp : m) {
    if (mp.second >= 2) ans += (mp.second) * (mp.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
