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