$("#button1").click(function () {
var chosenArray = [];
$('#chosen li:visible').each(function () {
You are hiding the
li
on delete. But when you create array you are taking all li
elements
you need to select only visible elements $('#chosen li:visible').
Read :visible