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