#include <bits/stdc++.h>
const long long int mxn = 2 * 1e5 + 7;
const long long int mod = 1e9 + 7;
const long long int inf = 1e18 + 9;
using namespace std;
long long int n, pr[mxn], a[mxn], cnt = 0, sum;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pr[i] = pr[i - 1] + a[i];
  }
  sort(pr, pr + n + 1);
  for (int i = 0; i <= n; i++) {
    if (pr[i] == pr[i + 1]) {
      cnt++;
    } else {
      sum += (cnt * (cnt + 1) / 2);
      cnt = 0;
    }
  }
  cout << sum;
  return 0;
}
