#include <bits/stdc++.h>
using namespace std;
int N;
map<int, int> cnt;
int main() {
  cin >> N;
  int s = 0;
  cnt[0] = 1;
  for (int i = (0); i < ((N)); i++) {
    int a;
    cin >> a;
    s += a;
    cnt[s] = cnt[s] + 1;
  }
  int ans = 0;
  for (auto iter = cnt.begin(); iter != cnt.end(); iter++) {
    ans += iter->second * (iter->second - 1) / 2;
  }
  cout << ans << endl;
}
