Time complexity using summation