function t = isback(A, p, amin, amax, n)
  if ((p-n) < 1)
    t = 1;
    return
  endif
  
  if ((p+n) > length(A))
    t = 1;
    return
  endif

  for i = p-n : p+n
    if (A(i) < amin)
      t = 0;
      return
    endif
    
    if (A(i) > amax)
      t = 0;
      return
    endif
  endfor

  t = 1;

endfunction
