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