calculate powers of numbers in an array