n = gets.to_i
xs = gets.split.map {|x| x.to_i}
xs << 10*12
l = gets.to_i
q = gets.to_i
as = []
bs = []


hsh = Hash.new
q.times { |_q|
  (astr,bstr) = gets.strip.split
  a = astr.to_i - 1
  b = bstr.to_i - 1
  as << a
  bs << b
  
  if (a>b)
    (b,a)=[a,b]
    (bstr,astr)=[astr,bstr]
  end

  #puts "#{a} #{b} #{l}"

  pos = a
  day = 0
  while pos <= b
    #puts "#{pos+1}"
    new_pos = pos
    while xs[new_pos+1] <= xs[pos] + l
      new_pos += 1
    end
    day += 1
    pos = new_pos
  end
  puts "#{day-1}"
  hsh[astr+":"+bstr] = day
}
