title: Dynamic programming doesn't give correct answer
body: <p>I recently found out about the technique called dynamic programming and I stumbled upon a problem which I can't figure out. You are given a list of arguments in the beginning and you need to do sums on as if you were cutting it. If the list has only one element, you don't sum it. If it has more, you sum the elements and cut it in every possible way. So if list has n elements, there are just n-1 ways to cut it. The picture will explain:</p>
  
  <p><a href="https://i.stack.imgur.com/uZhbB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uZhbB.png" alt="Opt"></a></p>
  
  <p>I first wanted to sum up all of the sumable parts and I expected the result 20( 11 + 9 ) ( even thought the correct answer is 9 ), but I thought it would be a good start. But my code returns number 37 and I have no idea why. What am I doing wrong?</p>
  
  <pre><code>summ = 0
  
  def Opt( n ):
      global summ
  
      if len( n ) == 1:
          return 0
      else:
          summ += sum( n )
          for i in range( 1,len( n ) ):
              summ += Opt( n[ :i ] ) + Opt( n[ i: ] )
  
          return summ
  
  print( Opt( [ 1,2,3 ] ) )
  </code></pre>
  
  <p>Thank you for your time and any answer!</p>