Sums of products of powers of given prime numbers