We sort the value of the coins in ascending order. After that, we start the test from the minimum. When for the next coin its value exceeds the sum of the previous coins by more than 1, the minimum amount that cannot be paid is equal to the sum of the previous coins + 1.
To simplify the software implementation (in order not to handle separately the case when there is no such coin, this is how it is in the original example) you can add a fake coin worth more than the sum of all the coins plus one to the set.
Schematically:
input "Количество монет=";n dim coins(0 to n) sum=0 for i = 0 to n-1 input coins(i) sum=sum+coins(i) next i coins(n)=sum+2 coins=sort(coins, asc) sum=0 for i = 0 to n if coins(i) > sum+1 then print sum+1 exit program else sum=sum+coins(i) end if next i