import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0))


if __name__=="__main__":
    main() import math math from math import gcd,pi,sqrt INF = float("inf") INF float("inf") float "inf" import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 import itertools itertools from collections import Counter,deque def i_input(): return int(input()) i_input def i_map(): return map(int, input().split()) i_map def i_list(): return list(i_map()) i_list i_input() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_input() i_input def i_row(N): return [i_input() for _ in range(N)] i_row N N i_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i_list() i_list def i_row_list(N): return [i_list() for _ in range(N)] i_row_list N N def s_input(): return input() s_input def s_map(): return input().split() s_map def s_list(): return list(s_map()) s_list s_input for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_input def s_row(N): return [s_input for _ in range(N)] s_row N N s_list() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) s_list() s_list def s_row_str(N): return [s_list() for _ in range(N)] s_row_str N N list(s_input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(s_input()) list s_input() s_input def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list N N def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0)) main n, A,B,C = i_map() n i_map() i_map A B C i_input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) i_input() i_input l = [i_input() for i in range(n)] l [i_input() for i in range(n)] def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
     dfs if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
         cur==n cur n return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF min(a,b,c) > 0 min(a,b,c) min a b c 0 abs(a-A) + abs(b-B) + abs(c-C) - 30 abs(a-A) + abs(b-B) + abs(c-C) abs(a-A) + abs(b-B) abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C 30 INF ret0 = dfs(cur+1, a,b,c) ret0 dfs(cur+1, a,b,c) dfs cur+1 cur 1 a b c ret1 = dfs(cur+1, a+l[cur],b,c) + 10 ret1 dfs(cur+1, a+l[cur],b,c) + 10 dfs(cur+1, a+l[cur],b,c) dfs cur+1 cur 1 a+l[cur] a l[cur] l cur b c 10 ret2 = dfs(cur+1, a,b+l[cur],c) + 10 ret2 dfs(cur+1, a,b+l[cur],c) + 10 dfs(cur+1, a,b+l[cur],c) dfs cur+1 cur 1 a b+l[cur] b l[cur] l cur c 10 ret3 = dfs(cur+1, a,b,c+l[cur]) + 10 ret3 dfs(cur+1, a,b,c+l[cur]) + 10 dfs(cur+1, a,b,c+l[cur]) dfs cur+1 cur 1 a b c+l[cur] c l[cur] l cur 10 return min(ret0, ret1,ret2, ret3) min(ret0, ret1,ret2, ret3) min ret0 ret1 ret2 ret3 cur cur a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def i_row_list(N): return [i_list() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] i_row_list def i_map(): return map(int, input().split()) def i_map(): return map(int, input().split()) i_map def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0)) def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0)) main INF = float("inf") float("inf") INF def s_row_str(N): return [s_list() for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] s_row_str def i_row(N): return [i_input() for _ in range(N)] def i_row(N): return [i_input() for _ in range(N)] i_row def s_input(): return input() def s_input(): return input() s_input def i_list(): return list(i_map()) def i_list(): return list(i_map()) i_list def s_row(N): return [s_input for _ in range(N)] def s_row(N): return [s_input for _ in range(N)] s_row def s_row_list(N): return [list(s_input()) for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] s_row_list def i_input(): return int(input()) def i_input(): return int(input()) i_input def s_list(): return list(s_map()) def s_list(): return list(s_map()) s_list def s_map(): return input().split() def s_map(): return input().split() s_map
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0))


if __name__=="__main__":
    main()
