# coding: utf-8

# https://atcoder.jp/contests/abc119


def main():
    N, A, B, C = map(int, input().split())
    ls = [None] * N
    for i in range(N):
        ls[i] = int(input())

    abc_mp = []

    def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

    rec(0, 0, 0, 0, 0, ls)
    a0, b0, c0, mp0 = abc_mp[0]
    ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0)
    for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

    return ans


print(main()) def main():
    N, A, B, C = map(int, input().split())
    ls = [None] * N
    for i in range(N):
        ls[i] = int(input())

    abc_mp = []

    def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

    rec(0, 0, 0, 0, 0, ls)
    a0, b0, c0, mp0 = abc_mp[0]
    ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0)
    for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

    return ans main N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C ls = [None] * N ls [None] * N [None] None N for i in range(N):
        ls[i] = int(input())

     i range(N) range N ls[i] = int(input()) ls[i] ls i int(input()) int input() input abc_mp = [] abc_mp [] def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

     rec if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

     i == len(ls) i len(ls) len ls if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
         a > 0 and b > 0 and c > 0 a > 0 and b > 0 a > 0 a 0 b > 0 b 0 c > 0 c 0 abc_mp.append([a, b, c, mp-30]) abc_mp.append abc_mp append [a, b, c, mp-30] a b c mp-30 mp 30 rec(i+1, a+ls[i], b, c, mp+10, ls) rec i+1 i 1 a+ls[i] a ls[i] ls i b c mp+10 mp 10 ls rec(i+1, a, b+ls[i], c, mp+10, ls) rec i+1 i 1 a b+ls[i] b ls[i] ls i c mp+10 mp 10 ls rec(i+1, a, b, c+ls[i], mp+10, ls) rec i+1 i 1 a b c+ls[i] c ls[i] ls i mp+10 mp 10 ls rec(i+1, a, b, c, mp, ls) rec i+1 i 1 a b c mp ls i i a a b b c c mp mp ls ls rec(0, 0, 0, 0, 0, ls) rec 0 0 0 0 0 ls a0, b0, c0, mp0 = abc_mp[0] a0 abc_mp[0] abc_mp 0 b0 c0 mp0 ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0) ans mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0) mp0 + abs(A-a0) + abs(B-b0) mp0 + abs(A-a0) mp0 abs(A-a0) abs A-a0 A a0 abs(B-b0) abs B-b0 B b0 abs(C-c0) abs C-c0 C c0 for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

     a b c mp abc_mp cand = mp + abs(A-a) + abs(B-b) + abs(C-c) cand mp + abs(A-a) + abs(B-b) + abs(C-c) mp + abs(A-a) + abs(B-b) mp + abs(A-a) mp abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c if cand < ans:
            ans = cand

     cand < ans cand ans ans = cand ans cand return ans ans print(main()) print main() main def main():
    N, A, B, C = map(int, input().split())
    ls = [None] * N
    for i in range(N):
        ls[i] = int(input())

    abc_mp = []

    def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

    rec(0, 0, 0, 0, 0, ls)
    a0, b0, c0, mp0 = abc_mp[0]
    ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0)
    for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

    return ans def main():
    N, A, B, C = map(int, input().split())
    ls = [None] * N
    for i in range(N):
        ls[i] = int(input())

    abc_mp = []

    def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

    rec(0, 0, 0, 0, 0, ls)
    a0, b0, c0, mp0 = abc_mp[0]
    ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0)
    for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

    return ans main
# coding: utf-8

# https://atcoder.jp/contests/abc119


def main():
    N, A, B, C = map(int, input().split())
    ls = [None] * N
    for i in range(N):
        ls[i] = int(input())

    abc_mp = []

    def rec(i, a, b, c, mp, ls):
        if i == len(ls):
            if a > 0 and b > 0 and c > 0:
                abc_mp.append([a, b, c, mp-30])
        else:
            rec(i+1, a+ls[i], b, c, mp+10, ls)
            rec(i+1, a, b+ls[i], c, mp+10, ls)
            rec(i+1, a, b, c+ls[i], mp+10, ls)
            rec(i+1, a, b, c, mp, ls)

    rec(0, 0, 0, 0, 0, ls)
    a0, b0, c0, mp0 = abc_mp[0]
    ans = mp0 + abs(A-a0) + abs(B-b0) + abs(C-c0)
    for a, b, c, mp in abc_mp:
        cand = mp + abs(A-a) + abs(B-b) + abs(C-c)
        if cand < ans:
            ans = cand

    return ans


print(main())
