Chemical peculiarities in magnetic and non-magnetic pre-main sequence A and B stars