Added Mth to last element solution