import sys
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = float('inf')
def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans

def main():
    print(dfs(0,0,0,0))

if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input L = [int(input()) for i in range(N)] L [int(input()) for i in range(N)] INF = float('inf') INF float('inf') float 'inf' def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans dfs if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
     i == N i N if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
     a==0 or b==0 or c==0 a==0 or b==0 a==0 a 0 b==0 b 0 c==0 c 0 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 ans0 = dfs(i+1, a, b, c) ans0 dfs(i+1, a, b, c) dfs i+1 i 1 a b c ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0) ans1 dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0) dfs(i+1, a+L[i], b, c) dfs i+1 i 1 a+L[i] a L[i] L i b c 10 if a != 0 else 0 a != 0 a 0 10 0 ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0) ans2 dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0) dfs(i+1, a, b+L[i], c) dfs i+1 i 1 a b+L[i] b L[i] L i c 10 if b != 0 else 0 b != 0 b 0 10 0 ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0) ans3 dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0) dfs(i+1, a, b, c+L[i]) dfs i+1 i 1 a b c+L[i] c L[i] L i 10 if c != 0 else 0 c != 0 c 0 10 0 ans = min(ans0, ans1, ans2, ans3) ans min(ans0, ans1, ans2, ans3) min ans0 ans1 ans2 ans3 return ans ans i i a a b b c c def main():
    print(dfs(0,0,0,0)) main 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 main():
    print(dfs(0,0,0,0)) def main():
    print(dfs(0,0,0,0)) main B, C = map(int, input().split()) map(int, input().split()) B L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L N, A, B, C = map(int, input().split()) map(int, input().split()) N def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans dfs C = map(int, input().split()) map(int, input().split()) C INF = float('inf') float('inf') INF input = sys.stdin.readline sys.stdin.readline input A, B, C = map(int, input().split()) map(int, input().split()) A
import sys
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = float('inf')
def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans

def main():
    print(dfs(0,0,0,0))

if __name__ == '__main__':
    main()