On orders of finite groups and centralizers of $p$-elements