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