Element 'k-maximum algorithm'