#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> s(n + 1, 0);
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    s[i] = a + s[i - 1];
  }
  sort(s.begin(), s.end());
  long res = 0;
  long same = s[0];
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] == same) {
      cnt++;
    } else {
      res += cnt * (cnt - 1) / 2;
      same = s[i];
      cnt = 1;
    }
  }
  res += cnt * (cnt - 1) / 2;
  cout << res << endl;
}
