#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000009;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

void solve(int n,int m){
	int s[20],d[110];
	for(int i = 0;i < n;i++) cin >> s[i];
	for(int i = 0;i < m;i++) cin >> d[i];
	int dp[1 << 15];
	for(int i = 0;i < (1 << n);i++) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0;i < m;i++) dp[0] += d[i];
	for(int i = 0;i < (1 << n);i++){
		int sum = 0;
		for(int j = 0;j < n;j++){
			if((i >> j) & 1) sum += s[j];
		}
		for(int j = 0;j < n;j++){
			if((i >> j) & 1) continue;
			int fukai = dp[i];
			for(int k = 0;k < m;k++){
				fukai -= max(0ll,abs(d[k] - sum) - abs(d[k] - (sum + s[j])));
			}
			chmin(dp[i | (1 << j)],fukai);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

signed main(){
	int n,m;
	while(cin >> n >> m,n){
		solve(n,m);
	}
}
