I have little basic knowledge about python, can build CMS with Django ,install,upgrade,uninstall python modules. I occur one question in fact work, and I fee Scipy can fix the question ,but I can't understand how to use Scipy and using which module or function even I have read two books about Numpy and Scipy in two weeks. So I have to seek help form somebody.

Here is the question's description ::

We have 50 numbers [A1,A2,A3,A4,A5,A6,A7,A8,A9...A50] and we also know the average of these numbers , for example the average is 3219, we will group the 50 numbers into 11 groups,So the average number 3218 and the sum of each group also will have 11 subtractions , and in the sum of 11 subtract abs value , the minimize one is our target. we wanna find the minimize sum of the 11 subtractions, and the group style of the 50 numbers.

1. We have 50 numbers [A1, A2, A3, ..., A49, A50] and the avg of these numbers: 3219;

2. Group these numbers in 11 groups :

S1 = x1_1*A1 + x2_1*A2 + x3_1*A3 + ... + x49_1*A49 + x50_1*A50;

S2 = x1_2*A1 + x2_2*A2 + x3_2*A3 + ... + x49_2*A49 + x50_2*A50;

S3 = x1_3*A1 + x2_3*A2 + x3_3*A3 + ... + x49_3*A49 + x50_3*A50;

.....

S11 = x1_11*A1 + x2_11*A2 + x3_11*A3 + ... + x49_11*A49 + x50_11*A50;

3.

F(X) = abs(S1-3219) + abs(S2-3219) + abs(S3-3219) + ... +abs(S11-3219)

4. LIMIT each one of the 50 numbers only in one group:

x1_1 + x1_2 + x1_3+ x1_4 + x1_5 + x1_6 + x1_7 + x1_8 + x1_9 + x1_10 + x1_11 = 1

x2_1 + x2_2 + x2_3+ x2_4 + x2_5 + x2_6 + x2_7 + x2_8 + x2_9 + x2_10 + x2_11 = 1

x3_1 + ...... + x2_11 = 1

...

x50_1 + ...... + x50_11 = 1

5. LIMIT each one of the x variables only can be 0 or 1;

x1_1 = {0,1}

x1_2 = {0,1}

.....

x50_11 = {0,1}

6.solve the minimize function:

minimize F(X)

Will anyone teach me how to solve this? I will be very thankful for your reply.