since it is a class A network so , first byte will be used for network id and the rest 3 byte will be used for subnet and host id.
Since , there should be 510 departments and hence the address space of the network should be divided into 510 parts.
so,the lefstmost 9 bit of the 3 byte will be 1 as it will be fixed to divide the add space in 512 parts.
Note - each 1 in the binary no divide it in 2 regions.
so,required subnet mask = 11111111 11111111 10000000 00000000
subnet mask is 255.255.128.0