ans [[n,m],a@(a1:as)] = maximum $ (a1-1):(ans' (a++[n+(n-al)]))
  where
    al = last a
ans [[n,m],a@(a1:as)] = maximum $ (a1-1):(ans' (a++[n+(n-al)]))
  where
    al = last a
ans [[n,m],a@(a1:as)] = maximum $ (a1-1):(ans' (a++[n+(n-al)]))
  where
    al = last a