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