If we are told there are $n$ inhabitants then the number of hairs each inhabitant can have is an element of the set $\\{0,1,2\dots n-1\\}$ because there are more inhabitants than hairs in the head of each inhabitant.
But if we want to reach the population of $n$ we must have exactly one inhabitant that has $0$ hairs, $1$ hair ... and so on until $n-1$ hairs.
When $n=618$ we can achieve this because $n-1$ is $617$ so the inhabitants can in fact have every possible hair quantity.
However when $n$ is $619$ or larger it is impossible to have inhabitants with each hair quantity between $0$ and $n-1$ because $618$ is forbidden.
Hence the maximum is $618$ inhabitants.