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;
        }

        auto cache = new int[][](M, 1 << N);
        foreach (ref a; cache) a[] = -1;
        int dfs(int k, int bit) {
            if (k == M) return 0;
            if (cache[k][bit] >= 0) return cache[k][bit];
            int d = D[k];
            int ans = int.max / 4;
            auto w = (1 << N) - 1 - bit;
            int s = w;
            do {
                int x = X[bit | s];
                ans = min(ans, dfs(k + 1, bit | s) + abs(d - x));
                s = (s - 1) & w;
            } while (s != w);
            return cache[k][bit] = ans;
        }

        writeln(dfs(0, 0));
    }
}