Assign properties of first array ellement to other array ellements. How?

Godot Version

Godot 4.2

Question

Im making RPG party system as 4 independent playable characters. One of them will be current_leader of the group and the others will follow him, like in Dragons Dogma 2, but the player could switch between characters at any time. I`ve managed to get progress(video). BUT there is a huge problem: follower target assign only works with full party. Because of strict references i made.

current_heroes: Array[PlayableCharacters]
index: int and is a keycode input
When the keycode 4 is pressed and the array consists of only 2 ellements the code gives the error that index is out of bounds.

Here is the code that is used to assign target for the unplayable characters:

    if index == 0:
		Player = current_heroes[0]
		set_playable_character(Player)
		current_heroes[1].target=Player
		current_heroes[2].target=current_heroes[1]
		current_heroes[3].target=current_heroes[2]
		set_camera_target(Player)
	elif index == 1:
		Player = current_heroes[1]
		current_heroes[2].target=Player
		current_heroes[3].target=current_heroes[2]
		current_heroes[0].target=current_heroes[3]
		set_playable_character(Player)
		set_camera_target(Player)
	elif index == 2:
		Player = current_heroes[2]
		current_heroes[3].target=Player
		current_heroes[0].target=current_heroes[3]
		current_heroes[1].target=current_heroes[0]
		set_playable_character(Player)
		set_camera_target(Player)
	elif index == 3:
		Player = current_heroes[3]
		current_heroes[0].target=Player
		current_heroes[1].target=current_heroes[0]
		current_heroes[2].target=current_heroes[1]
		set_playable_character(Player)
		set_camera_target(Player)

I wonder how can i refactor it so the code works with party array of any size. What would you suggest?