#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  mp[0] = 1;
  ll sum = 0;
  for (int i = 0; i < (N); i++) {
    int a;
    cin >> a;
    sum += a;
    mp[sum]++;
  }
  ll ans = 0;
  for (auto m : mp) {
    int n = m.second;
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
}
