#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<long long> a(n);
  long long buf = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      a.at(i) = buf;
    } else {
      a.at(i) = buf + a.at(i - 1);
    }
  }
  sort(a.begin(), a.end());
  int count = 1;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    if (a.at(i) != a.at(i - 1)) {
      ans += (count + 1) * count / 2;
      count = 1;
    } else {
      count++;
    }
  }
  ans += (count + 1) * count / 2;
  cout << ans << endl;
  return 0;
}
