add head and tail for array