Modified RMQ