Get all but the last element or last n elements of an array.