#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> data(N + 1);
  for (int i = 1; i < N + 1; i++) {
    cin >> data.at(i);
    data.at(i) += data.at(i - 1);
  }
  sort(data.begin(), data.end());
  int count = 0;
  long ans = 0;
  for (int i = 0; i < N; i++) {
    if (data.at(i + 1) == data.at(i))
      count++;
    else {
      ans += (count + 1) * count / 2;
      count = 0;
    }
  }
  ans += (count + 1) * count / 2;
  cout << ans << endl;
  return 0;
}
