import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C = I()
l = [i() for _ 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)) import sys sys import math math import itertools itertools import bisect bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() s def i(): return int(input()) i def S(): return input().split() S def I(): return map(int,input().split()) I def L(): return list(map(int,input().split())) L def l(): return list(map(int,input().split())) l def lcm(a,b): return a*b//math.gcd(a,b) lcm a a b b sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10**9 INF 10**9 10 9 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 N,A,B,C = I() N I() I A B C i() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) i() i l = [i() for _ in range(N)] l [i() for _ 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 def i(): return int(input()) def i(): return int(input()) i INF = 10**9 10**9 INF mod = 10**9+7 10**9+7 mod C = I() I() C def lcm(a,b): return a*b//math.gcd(a,b) def lcm(a,b): return a*b//math.gcd(a,b) lcm A,B,C = I() I() A l = [i() for _ in range(N)] [i() for _ in range(N)] l def I(): return map(int,input().split()) def I(): return map(int,input().split()) I def L(): return list(map(int,input().split())) def L(): return list(map(int,input().split())) L def s(): return input() def s(): return input() s 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) 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 def S(): return input().split() def S(): return input().split() S N,A,B,C = I() I() N def l(): return list(map(int,input().split())) def l(): return list(map(int,input().split())) l B,C = I() I() B
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C = I()
l = [i() for _ 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))