#include <bits/stdc++.h>
using namespace std;
map<int, int> used;
int main() {
  int n;
  cin >> n;
  used[0] = 1;
  int asd = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    asd += x;
    ans += used[asd];
    used[asd]++;
  }
  cout << ans << endl;
  ;
}
