Let X be a discrete random variable. Show that the expected value E(X) minimises the expected sum of squared distances,

i.e. show that for all a € R

with quality

The question also gives a hint that you can write

Once I expanded this im unsure what to do.