N, K = map( int, input().split() )
V = list( map( int, input().split() ) )
 
max_number = 0
for A in range( K + 1 ):
  for B in range( K + 1 ):
    J = K - A - B
    if J < 0:
      continue
    if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
    hand = sorted( hand )
      
    hand_num = 0
    for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
    max_number = max( max_number, sum( hand ))
print( max_number ) N, K = map( int, input().split() ) N map( int, input().split() ) map int input().split() ().split () input split K V = list( map( int, input().split() ) ) V list( map( int, input().split() ) ) list map( int, input().split() ) map int input().split() ().split () input split max_number = 0 max_number 0 for A in range( K + 1 ):
  for B in range( K + 1 ):
    J = K - A - B
    if J < 0:
      continue
    if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
    hand = sorted( hand )
      
    hand_num = 0
    for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
    max_number = max( max_number, sum( hand )) A range( K + 1 ) range K + 1 K 1 for B in range( K + 1 ):
    J = K - A - B
    if J < 0:
      continue
    if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
    hand = sorted( hand )
      
    hand_num = 0
    for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
    max_number = max( max_number, sum( hand )) B range( K + 1 ) range K + 1 K 1 J = K - A - B J K - A - B K - A K A B if J < 0:
      continue
     J < 0 J 0 continue if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
     A + B >= N A + B A B N hand = V hand V hand = V[ : A ] + V[ N - B : ] hand V[ : A ] + V[ N - B : ] V[ : A ] V : A A V[ N - B : ] V N - B : N - B N B hand = sorted( hand ) hand sorted( hand ) sorted hand hand_num = 0 hand_num 0 for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
     i j enumerate(hand) enumerate hand if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
     ( j > 0 ) or ( i == J ) j > 0 j 0 i == J i J hand = hand[ i: ] hand hand[ i: ] hand i: i break max_number = max( max_number, sum( hand )) max_number max( max_number, sum( hand )) max max_number sum( hand ) sum hand print( max_number ) print max_number hand = V[ : A ] + V[ N - B : ] V[ : A ] + V[ N - B : ] hand max_number = max( max_number, sum( hand )) max( max_number, sum( hand )) max_number J = K - A - B K - A - B J hand = hand[ i: ] hand[ i: ] hand hand = sorted( hand ) sorted( hand ) hand N, K = map( int, input().split() ) map( int, input().split() ) N V = list( map( int, input().split() ) ) list( map( int, input().split() ) ) V max_number = 0 0 max_number hand = V V hand hand_num = 0 0 hand_num K = map( int, input().split() ) map( int, input().split() ) K
N, K = map( int, input().split() )
V = list( map( int, input().split() ) )
 
max_number = 0
for A in range( K + 1 ):
  for B in range( K + 1 ):
    J = K - A - B
    if J < 0:
      continue
    if A + B >= N:
      hand = V
    else:
      hand = V[ : A ] + V[ N - B : ]
    hand = sorted( hand )
      
    hand_num = 0
    for i, j in enumerate(hand):
      if ( j > 0 ) or ( i == J ):
        hand = hand[ i: ]
        break
    max_number = max( max_number, sum( hand ))
print( max_number )