from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n, A, B, C = Is()
L = IR(n)

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

print(dfs(0, 0, 0, 0)) from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from copy import deepcopy from operator import itemgetter from functools import reduce from fractions import gcd import sys sys def input(): return sys.stdin.readline().rstrip() input def I(): return int(input()) I def Is(): return map(int, input().split()) Is def LI(): return list(map(int, input().split())) LI def TI(): return tuple(map(int, input().split())) TI I() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) I() I def IR(n): return [I() for _ in range(n)] IR n n LI() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LI() LI def LIR(n): return [LI() for _ in range(n)] LIR n n TI() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) TI() TI def TIR(n): return [TI() for _ in range(n)] TIR n n def S(): return input() S def Ss(): return input().split() Ss def LS(): return list(input()) LS S() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) S() S def SR(n): return [S() for _ in range(n)] SR n n Ss() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) Ss() Ss def SsR(n): return [Ss() for _ in range(n)] SsR n n LS() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) LS() LS def LSR(n): return [LS() for _ in range(n)] LSR n n sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 INF = float('inf') INF float('inf') float 'inf' n, A, B, C = Is() n Is() Is A B C L = IR(n) L IR(n) IR n def dfs(i, a, b, c):
    if i == n:
        return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(i+1, a, b, c)
    ret1 = dfs(i+1, a+L[i], b, c) + 10
    ret2 = dfs(i+1, a, b+L[i], c) + 10
    ret3 = dfs(i+1, a, b, c+L[i]) + 10
    return min(ret0, ret1, ret2, ret3) dfs if i == n:
        return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a, b, c) > 0 else INF
     i == n i 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(i+1, a, b, c) ret0 dfs(i+1, a, b, c) dfs i+1 i 1 a b c ret1 = dfs(i+1, a+L[i], b, c) + 10 ret1 dfs(i+1, a+L[i], b, c) + 10 dfs(i+1, a+L[i], b, c) dfs i+1 i 1 a+L[i] a L[i] L i b c 10 ret2 = dfs(i+1, a, b+L[i], c) + 10 ret2 dfs(i+1, a, b+L[i], c) + 10 dfs(i+1, a, b+L[i], c) dfs i+1 i 1 a b+L[i] b L[i] L i c 10 ret3 = dfs(i+1, a, b, c+L[i]) + 10 ret3 dfs(i+1, a, b, c+L[i]) + 10 dfs(i+1, a, b, c+L[i]) dfs i+1 i 1 a b c+L[i] c L[i] L i 10 return min(ret0, ret1, ret2, ret3) min(ret0, ret1, ret2, ret3) min ret0 ret1 ret2 ret3 i i a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 def TI(): return tuple(map(int, input().split())) def TI(): return tuple(map(int, input().split())) TI def LSR(n): return [LS() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] LSR def dfs(i, a, b, c):
    if i == n:
        return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(i+1, a, b, c)
    ret1 = dfs(i+1, a+L[i], b, c) + 10
    ret2 = dfs(i+1, a, b+L[i], c) + 10
    ret3 = dfs(i+1, a, b, c+L[i]) + 10
    return min(ret0, ret1, ret2, ret3) def dfs(i, a, b, c):
    if i == n:
        return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(i+1, a, b, c)
    ret1 = dfs(i+1, a+L[i], b, c) + 10
    ret2 = dfs(i+1, a, b+L[i], c) + 10
    ret3 = dfs(i+1, a, b, c+L[i]) + 10
    return min(ret0, ret1, ret2, ret3) dfs def SR(n): return [S() for _ in range(n)] def SR(n): return [S() for _ in range(n)] SR def LIR(n): return [LI() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] LIR def Is(): return map(int, input().split()) def Is(): return map(int, input().split()) Is def TIR(n): return [TI() for _ in range(n)] def TIR(n): return [TI() for _ in range(n)] TIR MOD = 10**9+7 10**9+7 MOD A, B, C = Is() Is() A def SsR(n): return [Ss() for _ in range(n)] def SsR(n): return [Ss() for _ in range(n)] SsR INF = float('inf') float('inf') INF def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input def IR(n): return [I() for _ in range(n)] def IR(n): return [I() for _ in range(n)] IR n, A, B, C = Is() Is() n def S(): return input() def S(): return input() S def LS(): return list(input()) def LS(): return list(input()) LS B, C = Is() Is() B def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def Ss(): return input().split() def Ss(): return input().split() Ss def I(): return int(input()) def I(): return int(input()) I C = Is() Is() C L = IR(n) IR(n) L
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n, A, B, C = Is()
L = IR(n)

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

print(dfs(0, 0, 0, 0))
