add edge cases n=1 and exclude the last item. sol of q054