my@a=0 xx 123;get;for lines>>.ords.sort { @a[.[*-1]]=max @a[.[*-1]],@a[^.[0]+1].max+$_ if $_ eq.sort } say @a.max