Largest sum of contiguous subarray + Exponentiation without built-in function