implemented outputing the values of the first and the last element.