#include <bits/stdc++.h>
using namespace std;
map<long long, long long> ma;
int main() {
  int a;
  cin >> a;
  vector<long long> num(a);
  vector<long long> sum(a);
  for (int i = 0; i < a; i++) {
    cin >> num[i];
    if (i != 0)
      sum[i] = sum[i - 1] + num[i];
    else
      sum[i] = num[i];
  }
  sort(sum.begin(), sum.end());
  long long ans = 0;
  for (int i = 0; i < a - 1; i++) {
    long long cnt = 1;
    while (sum[i] == sum[i + 1] && i < a - 1) {
      cnt++;
      i++;
    }
    if (i == a - 2 && sum[i] == sum[i + 1]) cnt++;
    if (sum[i] == 0)
      ans += (cnt * (cnt + 1)) / 2;
    else
      ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
