array implementation for exponentiation