# https://atcoder.jp/contests/abc062/tasks/arc074_b
# in
# 3
# 8 2 2 7 4 6 5 3 8
# out
# 5
class PopHeap
  attr_accessor :nodes, :size
  def initialize(n)
    @nodes = Array.new(n)
    @size = 0
  end

  def push(x)
    current_index = @size
    @size += 1
    while current_index > 0 do
      parent_index = (current_index - 1)>>1
      parent_value = @nodes[parent_index]
      break if parent_value <= x
      @nodes[current_index] = parent_value
      current_index = parent_index
    end
    @nodes[current_index] = x
  end

  def pop
    top = @nodes[0]
    current_node_index = 0
    current_node_value = @nodes[0] = @nodes[@size - 1]
    @nodes[@size - 1] = nil
    @size -= 1

    while
      child_node_index_r = (current_node_index + 1) << 1
      child_node_index_l = child_node_index_r - 1
      return top unless child_node_index_l < @size
      child_node_value_l = @nodes[child_node_index_l]
      child_node_value_r = @nodes[child_node_index_r]
      if child_node_value_r&.<child_node_value_l
        min_child_value = child_node_value_r
        min_child_index = child_node_index_r
      else
        min_child_value = child_node_value_l
        min_child_index = child_node_index_l
      end
      return top unless min_child_value < current_node_value
      change(current_node_index, min_child_index)
      current_node_index = min_child_index
    end
  end

  private

  def change(index_i, index_j)
    @nodes[index_i], @nodes[index_j] = @nodes[index_j], @nodes[index_i]
  end
end

class ReversePopHeap
  attr_accessor :nodes, :size
  def initialize(n)
    @nodes = Array.new(n)
    @size = 0
  end

  def push(x)
    current_index = @size
    @size += 1
    while current_index > 0 do
      parent_index = (current_index - 1)>>1
      parent_value = @nodes[parent_index]
      break if parent_value >= x
      @nodes[current_index] = parent_value
      current_index = parent_index
    end
    @nodes[current_index] = x
  end

  def pop
    top = @nodes[0]
    current_node_index = 0
    current_node_value = @nodes[0] = @nodes[@size - 1]
    @nodes[@size - 1] = nil
    @size -= 1

    while
      child_node_index_r = (current_node_index + 1) << 1
      child_node_index_l = child_node_index_r - 1
      return top unless child_node_index_l < @size
      child_node_value_l = @nodes[child_node_index_l]
      child_node_value_r = @nodes[child_node_index_r]
      if child_node_value_r&.>child_node_value_l
        max_child_value = child_node_value_r
        max_child_index = child_node_index_r
      else
        max_child_value = child_node_value_l
        max_child_index = child_node_index_l
      end
      return top unless max_child_value > current_node_value
      change(current_node_index, max_child_index)
      current_node_index = max_child_index
    end
  end

  private

  def change(index_i, index_j)
    @nodes[index_i], @nodes[index_j] = @nodes[index_j], @nodes[index_i]
  end
end


N = gets.to_i
a3n = gets.split.map(&:to_i).to_a
r_a3n = a3n.reverse

a3n_mae = PopHeap.new(1)
a3n_ushiro = ReversePopHeap.new(1)

mae = []
ushiro = []
sum_mae = 0
sum_ushiro = 0
N.times do |i|
  a3n_mae.push(a3n[i])
  sum_mae += a3n[i]
  a3n_ushiro.push(a3n[3*N - 1 - i])
  sum_ushiro += a3n[3*N - 1 - i]
end
mae[0] = sum_mae
ushiro[0] = sum_ushiro

N.times do |i|
  a3n_mae.push(a3n[N+i])
  v = a3n_mae.pop
  mae[i + 1] = mae[i] + a3n[N+i] - v

  a3n_ushiro.push(a3n[2*N - 1 - i])
  v = a3n_ushiro.pop
  ushiro[i + 1] = ushiro[i] + a3n[2*N - 1 - i] - v
end
ans_k = (0..N).to_a.max_by { |i| mae[i] - ushiro[N-i] }
p mae[ans_k] - ushiro[N-ans_k]

Measured memory_bytes: 38696