#Mathematica, 65 f=-Order@@MapIndexed[If[#>Last@#2,#,a-b#]&,PadRight[{##}+1],{2}]& Usage: f[{1, 2, 1, 1, 6}, {1, 2, 1, 1, 7}] > -1