#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    int N,M;
    while(cin >> N >> M){
        if(N==0&&M==0) break;
        vector<LL> s(N),d(M),ac(1<<N);
        for(int i=0;i<N;i++) cin >> s[i];
        for(int i=0;i<M;i++) cin >> d[i];
        for(int i=0;i<(1<<N);i++){
            for(int j=0;j<N;j++){
                if(i&(1<<j)) ac[i]+=s[j];
            }
        }
        sort(All(d));
        LL dp[M+1][1<<N];
        memset(dp,0,sizeof(dp));
        for(int m=0;m<M;m++){
            for(int k=0;k<(1<<N);k++){
                dp[m+1][k]=dp[m][k]+abs(ac[k]-d[m]);
                for(int s=0;s<N;s++){
                    if(k&(1<<s)){
                        int p=k^(1<<s);
                        dp[m+1][k]=min(dp[m+1][k],dp[m+1][p]);
                    }
                }
            }
        }
        cout << dp[M][(1<<N)-1] << endl;
    }
    return 0;
}
