Hmmm - wouldn't the unselected subject codes just be those from the database that hadn't been selected.
You know the subjects available and you know the subjects which have been selected, therefore you know the subjects which haven't been selected.
If you wanted to select them from the database you could loop through the selected array and construct your SQL statement so that only unselected subjects were returned (or conversely you could just select all subjects again and filter them in PHP, but I prefer to give SQL all the hard work to do 🙂 )
NB - make sure you don't generate a massively long SQL string, cos (MySQL especially) will throw a fit (don't ask me how I managed to find this one out 🙂 )