Add to list - index position

I have a list of 58 numbers

{“1905”, “1905”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1906”, “1907”}

I use this list to place a graphic at a specific index position on an Adobe InDesign page that contains 60 boxes.
What I am trying to do is find the index position in the list where the number change.
For instance at index positions 3 and 58 of the above list the number changes.
The problem is that the index position 58 should be 59 on the Adobe InDesign page.

I think this may work


set x to {"1905", "1905", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1907"}

set newLIST to {}
set theCNT to count of x
--set newLIST to item 1 of x
repeat with i from 2 to count of x
	if item (i - 1) of x is not equal to item i of x and i is less than theCNT then
		set end of newLIST to item (i - 1) of x
		set end of newLIST to "IMAGE" & item i of x as text
		set end of newLIST to item i of x
	else if i is equal to theCNT then
		set end of newLIST to "IMAGE" & item i of x as text
		set end of newLIST to item i of x
	else
		set end of newLIST to item i of x
	end if
end repeat
newLIST
--{"1905", "1905", "IMAGE1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "IMAGE1907", "1907"}

Ok that first script did not allow for other possible numbers

set x to {"1905", "1905", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1907", "1908", "1908", "1908"}

set newLIST to {}
set theCNT to count of x


--No image at position 1. Start loop from position 2

repeat with i from 2 to count of x
	if item (i - 1) of x is not equal to item i of x and i is less than theCNT then
		set end of newLIST to item (i - 1) of x
		set end of newLIST to "AIMAGE" & item i of x as text
	else if item (i - 1) of x is not equal to item i of x and i is equal to theCNT then
		set end of newLIST to item (i - 1) of x
		set end of newLIST to "BIMAGE" & item i of x as text
		set end of newLIST to item i of x
	else if item (i - 1) of x is equal to item i of x and i is equal to theCNT then
		set end of newLIST to item (i - 1) of x
		set end of newLIST to item i of x
	else
		set end of newLIST to item i of x
	end if
end repeat
newLIST
--{"1905", "1905", "AIMAGE1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "1906", "AIMAGE1907", "1907", "AIMAGE1908", "1908", "1908", "1908"}

There probably is an easier way to do this.
If you have any suggestions let me know

I use this to add items in at an index into a list, but I don’t know it’s useful to you?

set myList to {1, 2, 3, 4, 6, 7, 8, 9, 10}
addItemAtIndex(5, myList, 5)

on addItemAtIndex(anItem, aList, anIndex)
	if (count aList) < anIndex then return
	
	if ((count aList) + 1) is anIndex then
		set end of aList to anItem
		return aList
	end if
	
	set newList to (items 1 thru (anIndex - 1)) of aList
	set end of newList to anItem
	repeat with i from anIndex to (count aList)
		set end of newList to item i of aList
	end repeat
	
	return newList
end addItemAtIndex

Hope it is useful,
ief2