A refinement of Lang's formula for the sums of powers of integers