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