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

#define INF 1e9

int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    vector<int> s(n);
    vector<int> d(m);
    for(int i = 0; i < n; i++){ cin >> s[i]; }
    for(int i = 0; i < m; i++){ cin >> d[i]; }
    sort(d.begin(), d.end());
    
    vector<int> sum_s(1 << n, 0);
    for(int i = 0; i < (1 << n); i++)
      for(int j = 0; j < n; j++)
        if((i & (1 << j)) != 0)
          sum_s[i] += s[j];

    
    vector<vector<int> > dp(m, vector<int>(1 << n, INF));
    for(int i = 0; i < (1 << n); i++)
      dp[0][i] = abs(d[0] - sum_s[i]);
    
    for(int i = 1; i < m; i++){
      for(int j = 0; j < (1 << n); j++){
        dp[i][j] = dp[i - 1][j] + abs(d[i] - sum_s[j]);
        for(int k = 0; k < n; k++){
          if((j & (1 << k)) == 0){ continue; }
          int before = j & (~(1 << k));
          dp[i][j] = min(dp[i][j], dp[i][before] - abs(d[i] - sum_s[before]) + abs(d[i] - sum_s[j]));
        }
      }
    }
            
    int ans = INF;
    for(int i = 0; i < (1 << n); i++)
      ans = min(ans, dp[m - 1][i]);
    cout << ans << endl;
    
  }
  
  return 0;
}