import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

void main() {
    while (true) {
        int N, M; readf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) break;
        auto S = readln.chomp.split(" ").map!(to!int).array;
        auto D = readln.chomp.split(" ").map!(to!int).array;
        D.sort;

        auto X = new int[1 << N];
        foreach (int bit; 0 .. (1 << N)) {
            int x = 0;
            foreach (int i; 0 .. N) {
                if (bit & (1 << i)) 
                    x += S[i];
            }
            X[bit] = x;
        }

        const int INF = int.max / 2;

        auto dp = new int[][](M + 1, 1 << N);
        foreach (ref a; dp) a[] = INF;
        dp[M][] = 0;
        auto dp_min = new int[][](M, 1 << N);
        foreach (ref a; dp_min) a[] = INF;
        foreach_reverse (int k; 0 .. M) {
            foreach (int bit; 0 .. 1 << N) {
                dp_min[k][bit] = min(dp_min[k][bit], dp[k + 1][bit] + abs(D[k] - X[bit]));
            }
            foreach_reverse (int j; 1 .. N + 1) {
                int bit = (1 << j) - 1;
                while (bit < (1 << N)) {
                    foreach (int l; 0 .. N) {
                        if (! (bit & (1 << l))) continue;
                        //stderr.writefln("%b", 1<<N);
                        //stderr.writefln("%b", bit - (1 << l));
                        dp_min[k][bit & ~(1<<l)] = min(dp_min[k][bit & ~(1<<l)], dp_min[k][bit]);
                    }
                    int x = bit & -bit, y = bit + x;
                    bit = ((bit & ~y)/ x >> 1) | y;
                }
            }
            foreach (int bit; 0 .. 1 << N) {
                dp[k][bit] = min(dp[k][bit], dp_min[k][bit]);
            }
        }

        writeln(dp[0][0]);
    }
}