import math
import collections
from operator import mul
from functools import reduce
import bisect
import string

numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(input())

def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s


mp=10000000000000000
for i in range(4**n):
    A=0
    B=0
    C=0
    ai=0
    bi=0
    ci=0
    s=base_cvt(str(i),4)
    s=zeropad(s,n)
    for j in range(n):
        if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
    if ai>0 and bi>0 and ci>0:
        mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c))


print(mp)








 import math math import collections collections from operator import mul from functools import reduce import bisect bisect import string string numbers = "0123456789" numbers "0123456789" alphabets = string.ascii_letters alphabets string.ascii_letters string ascii_letters characters = numbers + alphabets characters numbers + alphabets numbers alphabets def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result base_cvt try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
     except:
        raise ValueError('Invalid value:', value)
 
     raise ValueError('Invalid value:', value) ValueError('Invalid value:', value) ValueError 'Invalid value:' value tmp = int(value) tmp int(value) int value if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
     n < 2 or n > len(characters) n < 2 n 2 n > len(characters) n len(characters) len characters raise ValueError('Invalid n:', value) ValueError('Invalid n:', value) ValueError 'Invalid n:' value result = '' result '' tmp = int(value) tmp int(value) int value while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
     tmp >= n tmp n idx = tmp%n idx tmp%n tmp n result = characters[idx] + result result characters[idx] + result characters[idx] characters idx result tmp = int(tmp / n) tmp int(tmp / n) int tmp / n tmp n idx = tmp%n idx tmp%n tmp n result = characters[idx] + result result characters[idx] + result characters[idx] characters idx result return result result value value n=2 n 2 n,a,b,c=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c l=[0]*n l [0]*n [0] 0 n for i in range(n):
    l[i]=int(input()) i range(n) range n l[i]=int(input()) l[i] l i int(input()) int input() input def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s zeropad while len(s)<i:
        s="0"+s
     len(s)<i len(s) len s i s="0"+s s "0"+s "0" s return s s s s i i mp=10000000000000000 mp 10000000000000000 for i in range(4**n):
    A=0
    B=0
    C=0
    ai=0
    bi=0
    ci=0
    s=base_cvt(str(i),4)
    s=zeropad(s,n)
    for j in range(n):
        if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
    if ai>0 and bi>0 and ci>0:
        mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) i range(4**n) range 4**n 4 n A=0 A 0 B=0 B 0 C=0 C 0 ai=0 ai 0 bi=0 bi 0 ci=0 ci 0 s=base_cvt(str(i),4) s base_cvt(str(i),4) base_cvt str(i) str i 4 s=zeropad(s,n) s zeropad(s,n) zeropad s n for j in range(n):
        if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
     j range(n) range n if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
     s[j]=='1' s[j] s j '1' A+=l[j] A l[j] l j ai+=1 ai 1 elif s[j]=='2':
            B+=l[j]
            bi+=1
         s[j]=='2' s[j] s j '2' B+=l[j] B l[j] l j bi+=1 bi 1 elif s[j]=='3':
            C+=l[j]
            ci+=1
     s[j]=='3' s[j] s j '3' C+=l[j] C l[j] l j ci+=1 ci 1 if ai>0 and bi>0 and ci>0:
        mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) ai>0 and bi>0 and ci>0 ai>0 and bi>0 ai>0 ai 0 bi>0 bi 0 ci>0 ci 0 mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) mp min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) min mp 10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c) 10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b) 10*((ai-1)+(bi-1)+(ci-1))+abs(A-a) 10*((ai-1)+(bi-1)+(ci-1)) 10 (ai-1)+(bi-1)+(ci-1) (ai-1)+(bi-1) ai-1 ai 1 bi-1 bi 1 ci-1 ci 1 abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c print(mp) print mp characters = numbers + alphabets numbers + alphabets characters n,a,b,c=map(int,input().split()) map(int,input().split()) n a,b,c=map(int,input().split()) map(int,input().split()) a B+=l[j] l[j] B ci=0 0 ci s=base_cvt(str(i),4) base_cvt(str(i),4) s bi+=1 1 bi mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c)) mp s=zeropad(s,n) zeropad(s,n) s A+=l[j] l[j] A numbers = "0123456789" "0123456789" numbers C+=l[j] l[j] C B=0 0 B b,c=map(int,input().split()) map(int,input().split()) b l=[0]*n [0]*n l mp=10000000000000000 10000000000000000 mp c=map(int,input().split()) map(int,input().split()) c C=0 0 C ai+=1 1 ai def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s zeropad ci+=1 1 ci alphabets = string.ascii_letters string.ascii_letters alphabets ai=0 0 ai A=0 0 A def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result base_cvt bi=0 0 bi
import math
import collections
from operator import mul
from functools import reduce
import bisect
import string

numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(input())

def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s


mp=10000000000000000
for i in range(4**n):
    A=0
    B=0
    C=0
    ai=0
    bi=0
    ci=0
    s=base_cvt(str(i),4)
    s=zeropad(s,n)
    for j in range(n):
        if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
    if ai>0 and bi>0 and ci>0:
        mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c))


print(mp)









