title: How to get sum of products of all combinations in an array in Python?
body: <p>I'm using Python and 
  I'm given an array like <code>a = [1, 2, 3, 4]</code>
  and I want to find sum of all possible combination multiplications like:</p>
  
  <p>For combinations of 1: <code>1 + 2 + 3 + 4</code></p>
  
  <p>For combinations of 2:<code>1*2 + 2*3 + 3*4 + 4*1</code>.</p>
  
  <p>For combination of 3: <code>1*2*3 + 1*3*4 + 2*3*4</code></p>
  
  <p>For combinations of 4: <code>1*2*3*4</code></p>
  
  <p>And finally sum of all these sums is my answer. I'm using <code>numpy.prod()</code> and <code>numpy.sum()</code>. But it's still too slow. Is there some better algorithm to find the sum quickly?</p>