Node = Struct.new(:leaf, :value, :left, :right)

def make_leaf
    Node.new(true)
end

def make_branch(left, right)
  Node.new(false, nil, left, right)
end

def count(nminus)
    res = 0
    @N.times {|i|
        if (i < nminus)
          res -= @As[i];
        else
          res += @As[i];
        end
    }
    return res;
end

def make_tree(a, b)
  if (a + b == 1)
      if (a == 1)
        return make_leaf();
      else
        printf("tukurenai\n"); exit(1);
      end
  else
      x = 1
      z = 1
      y = b - z;
      w = a - x;
      return make_branch(make_tree(x, y), make_tree(z, w));
  end
end

@used_plus = 0;
@used_minus = 0;

def f(node, minus)
  if (node.leaf)
    if (minus)
      node.value = @As[@used_minus]
      @used_minus += 1
    else
      node.value = @As[@N - 1 - @used_plus]
      @used_plus += 1
    end
  else
    f(node.left, minus);
    f(node.right, !minus);
  end
end

def g(node)
  if (node.leaf)
      return node.value;
  else
    x = g(node.left);
    y = g(node.right);
    puts "#{x} #{y}"
    return x - y;
  end
end

def show(nminus)
  nplus = @N - nminus;
  node = make_tree(@N - nminus, nminus);
  f(node, false);
  res = g(node);
end

def main()
  @N = gets.to_i
  @As = gets.split(" ").map(&:to_i)
  @As.sort!
  best = 0;
  @N.times {|i|
    best = i  if (@As[i] < 0)
  }
  m = -1
  argmax = 0
  (-1..1).each {|i|
    j = [[best + i, 1].max, @N - 1].min
    c = count(j)
    if c > m
      m = c
      argmax = j
    end
  }
  puts m
  show argmax
end

main