#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

n,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(n)]
inf=10**9
def rec(i,a,b,c):
    if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
    res=rec(i+1,a,b,c)
    res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
    res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
    res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

    return res
print(rec(0,0,0,0)) from collections import deque import bisect bisect n,A,B,C=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l=[int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] inf=10**9 inf 10**9 10 9 def rec(i,a,b,c):
    if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
    res=rec(i+1,a,b,c)
    res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
    res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
    res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

    return res rec if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
     i==n i n if not a or not b or not c:
            return inf
         not a or not b or not c not a or not b not a a not b b not c c return inf inf return abs(A-a)+abs(B-b)+abs(C-c) 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 res=rec(i+1,a,b,c) res rec(i+1,a,b,c) rec i+1 i 1 a b c res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0)) res min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0)) min res rec(i+1,a+l[i],b,c)+(10 if a else 0) rec(i+1,a+l[i],b,c) rec i+1 i 1 a+l[i] a l[i] l i b c 10 if a else 0 a 10 0 res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0)) res min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0)) min res rec(i+1,a,b+l[i],c)+(10 if b else 0) rec(i+1,a,b+l[i],c) rec i+1 i 1 a b+l[i] b l[i] l i c 10 if b else 0 b 10 0 res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0)) res min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0)) min res rec(i+1,a,b,c+l[i])+(10 if c else 0) rec(i+1,a,b,c+l[i]) rec i+1 i 1 a b c+l[i] c l[i] l i 10 if c else 0 c 10 0 return res res i i a a b b c c print(rec(0,0,0,0)) print rec(0,0,0,0) rec 0 0 0 0 A,B,C=map(int,input().split()) map(int,input().split()) A inf=10**9 10**9 inf def rec(i,a,b,c):
    if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
    res=rec(i+1,a,b,c)
    res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
    res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
    res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

    return res def rec(i,a,b,c):
    if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
    res=rec(i+1,a,b,c)
    res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
    res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
    res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

    return res rec B,C=map(int,input().split()) map(int,input().split()) B n,A,B,C=map(int,input().split()) map(int,input().split()) n l=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l C=map(int,input().split()) map(int,input().split()) C
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

n,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(n)]
inf=10**9
def rec(i,a,b,c):
    if i==n:
        if not a or not b or not c:
            return inf
        return abs(A-a)+abs(B-b)+abs(C-c)
    res=rec(i+1,a,b,c)
    res=min(res,rec(i+1,a+l[i],b,c)+(10 if a else 0))
    res=min(res,rec(i+1,a,b+l[i],c)+(10 if b else 0))
    res=min(res,rec(i+1,a,b,c+l[i])+(10 if c else 0))

    return res
print(rec(0,0,0,0))