#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  long long a, total = 0;
  vector<int> b;
  b.push_back(total);
  for (int i = 0; i < n; i++) {
    cin >> a;
    total += a;
    b.push_back(total);
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == b[i + 1]) {
      ++cnt;
    } else {
      ++cnt;
      ans += cnt * (cnt - 1) / 2;
      cnt = 0;
    }
  }
  ++cnt;
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
}
