title: Sum of every element with every other element in a list
body: <p>I am solving a problem in which I need to find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.</p>
  
  <blockquote>
    <p>Abundant Numbers :A number n is called abundant if the sum of its
    proper divisors is greater than n . And by mathematical analysis, it
    can be shown that all integers greater than 28123 can be written as
    the sum of two abundant numbers.</p>
  </blockquote>
  
  <p>My approach for this problem is :
  I have a list of abundant numbers and I am finding the sum of every number with every other number in the list. When I have all the new_numbers (sum of the numbers in the abundant numbers list) I will check the numbers which are not in the list and sum them.</p>
  
  <p>But the part where I have to find sum of every number with others takes O(n^2) time . Is there a way to improve the complexity ?</p>
  
  <p>Here's my code with sample example :</p>
  
  <pre><code>k=[1,2,3]    # actual list with 7427 numbers 
  l=[]
  for i in k:
      for j in k[k.index(i):]:
          if i+j&lt;28123 and i+j not in l:
              l.append(i+j)
  print l,len(l)
  
  # result --&gt;[2, 3, 4, 5, 6] 5
  </code></pre>
  
  <p>Actually this is a <a href="https://projecteuler.net/problem=23" rel="nofollow">project euler </a> question.</p>