scoreboard players set min times_appeared 0

execute if score #heavy_helmet shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = heavy_helmet times_appeared
execute if score #heavy_helmet shop matches 1 if score heavy_helmet times_appeared < min times_appeared run scoreboard players operation min times_appeared = heavy_helmet times_appeared

execute if score #lagged_armor shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = lagged_armor times_appeared
execute if score #lagged_armor shop matches 1 if score lagged_armor times_appeared < min times_appeared run scoreboard players operation min times_appeared = lagged_armor times_appeared

execute if score #scaled_chestplate shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = scaled_chestplate times_appeared
execute if score #scaled_chestplate shop matches 1 if score scaled_chestplate times_appeared < min times_appeared run scoreboard players operation min times_appeared = scaled_chestplate times_appeared

execute if score #basic_mage_pants shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = basic_mage_pants times_appeared
execute if score #basic_mage_pants shop matches 1 if score basic_mage_pants times_appeared < min times_appeared run scoreboard players operation min times_appeared = basic_mage_pants times_appeared

execute if score #creeper_legs shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = creeper_legs times_appeared
execute if score #creeper_legs shop matches 1 if score creeper_legs times_appeared < min times_appeared run scoreboard players operation min times_appeared = creeper_legs times_appeared

execute if score #life_shoes shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = life_shoes times_appeared
execute if score #life_shoes shop matches 1 if score life_shoes times_appeared < min times_appeared run scoreboard players operation min times_appeared = life_shoes times_appeared
execute if score min times_appeared matches -1 run scoreboard players set min times_appeared 0