#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int DP[101][2<<15];
int W[2<<15];

int main(){
    int N,M;
    while(cin>>N>>M,N){
        vector<int> S(N);
        vector<int> D(M);
        for(auto &s:S)cin>>s;
        for(auto &d:D)cin>>d;
        sort(S.begin(), S.end());
        sort(D.begin(), D.end());
        fill(DP[0],DP[M+1],200000000);
        fill(DP[0],DP[1],0);
        for(int b=0;b<(1<<N);b++){
            W[b]=0;
            for(int n=0;n<N;n++){
                if(b&(1<<n))W[b]+=S[n];
            }
        }
        for(int i=1;i<=M;i++){
            for(int b=0;b<(1<<N);b++){
                DP[i][b]=min(DP[i][b],abs(W[b]-D[i-1])+DP[i-1][b]);
                for(int n=0;n<N;n++){
                    if(b&(1<<n))
                        DP[i][b]=min(DP[i][b],DP[i][b^(1<<n)]);
                }
            }
        }
        int ans=200000000;
        for(int b=0;b<(1<<N);b++){
            ans = min(DP[M][b],ans);
        }
        cout<<ans<<endl;
    }
    return 0;
}