#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<long long> bubun;
  cin >> N;
  long long temp;
  cin >> temp;
  bubun.push_back(temp);
  for (int i = 1; i < N; i++) {
    cin >> temp;
    bubun.push_back(bubun[i - 1] + temp);
  }
  stable_sort(bubun.begin(), bubun.end());
  vector<int> count;
  int count_0 = 0;
  long long temp2 = bubun[0];
  if (bubun[0] == 0) {
    count_0++;
    count.push_back(0);
  } else {
    count.push_back(1);
  }
  for (int i = 1; i < N; i++) {
    if (bubun[i] == 0) {
      count_0++;
    } else if (bubun[i] == temp2) {
      count[count.size() - 1]++;
    } else {
      temp2 = bubun[i];
      count.push_back(1);
    }
  }
  long long ans = 0;
  ans += (count_0 + 1) * count_0 / 2;
  for (int i = 0; i < count.size(); i++) {
    ans += count[i] * (count[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
