I have only one doubt here:

One way :

We know probability for every person getting right hat is 1/100 hence

Expectation = 1*(1/100) + 1*(1/100) + 1*(1/100) + ... 100 times = 1

Its the answer.

Another way :

If there are 100 person from 1,2...100

then it should be : 1*(1/100) + 2*(1/100) + 3*(1/100) + ........ = 50.5

How to know which one to use

Answer is 1 though

One way :

We know probability for every person getting right hat is 1/100 hence

Expectation = 1*(1/100) + 1*(1/100) + 1*(1/100) + ... 100 times = 1

Its the answer.

Another way :

If there are 100 person from 1,2...100

then it should be : 1*(1/100) + 2*(1/100) + 3*(1/100) + ........ = 50.5

How to know which one to use

Answer is 1 though