delete action in the first and the last elements respectively