#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e+9 + 7;
const double PI = acos(-1.0);
int main() {
  int n;
  cin >> n;
  vector<int> sum;
  sum.push_back(0);
  int input;
  for (int i = int(0); i < int(n); i++) {
    cin >> input;
    sum.push_back(sum[i] + input);
  }
  sort(sum.begin(), sum.end());
  long long ret = 0;
  long long cnt = 1;
  for (int i = int(0); i < int(n); i++) {
    if (sum[i] == sum[i + 1])
      cnt++;
    else {
      ret += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ret += cnt * (cnt - 1) / 2;
  cout << ret << "\n";
}
