Suppose I have a list [a1,a2.....a40], then I want to select a2,a3,a7,a8,a9 and check if a2+a3+a7+a8+a9=500 if yes I print it and then select other 5 numbers from the main array and check for the sum,keep repeating until and unless I've used all possible combinations.How to do so in python or Matlab.Any ideas will be helpful.