import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0))

if __name__=='__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0)) main 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 dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
     dfs if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
         cur==n cur n return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF aa*bb*cc>0 aa*bb*cc aa*bb aa bb cc 0 abs(aa-a)+abs(bb-b)+abs(cc-c)-30 abs(aa-a)+abs(bb-b)+abs(cc-c) abs(aa-a)+abs(bb-b) abs(aa-a) abs aa-a aa a abs(bb-b) abs bb-b bb b abs(cc-c) abs cc-c cc c 30 INF ret0=dfs(cur+1,aa,bb,cc) ret0 dfs(cur+1,aa,bb,cc) dfs cur+1 cur 1 aa bb cc ret1=dfs(cur+1,aa+L[cur],bb,cc)+10 ret1 dfs(cur+1,aa+L[cur],bb,cc)+10 dfs(cur+1,aa+L[cur],bb,cc) dfs cur+1 cur 1 aa+L[cur] aa L[cur] L cur bb cc 10 ret2=dfs(cur+1,aa,bb+L[cur],cc)+10 ret2 dfs(cur+1,aa,bb+L[cur],cc)+10 dfs(cur+1,aa,bb+L[cur],cc) dfs cur+1 cur 1 aa bb+L[cur] bb L[cur] L cur cc 10 ret3=dfs(cur+1,aa,bb,cc+L[cur])+10 ret3 dfs(cur+1,aa,bb,cc+L[cur])+10 dfs(cur+1,aa,bb,cc+L[cur]) dfs cur+1 cur 1 aa bb cc+L[cur] cc L[cur] L cur 10 return min(ret0,ret1,ret2,ret3) min(ret0,ret1,ret2,ret3) min ret0 ret1 ret2 ret3 cur cur aa aa bb bb cc cc 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 input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0)) def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0)) main
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0))

if __name__=='__main__':
    main()