fun maxScore(xs: List<IndexedValue<Long>>): Long {
  val vs = xs.map { it.value }
  if (vs.max()!! < 0) {
    return vs.max()!!
  } else {
    return vs.filter { it >= 0 }.sum()
  }
}

fun elementsForMaxScore(xs: List<IndexedValue<Long>>): List<IndexedValue<Long>> {
  if (maxScore(xs) < 0) {
    val max = maxScore(xs)
    return listOf(xs.first { it.value == max })
  } else {
    return xs.filter { it.value >= 0 }
  }
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = readLine()!!.split(" ").map(String::toLong)
  val evens = xs.withIndex().filter { it.index % 2 == 0 }
  val odds = xs.withIndex().filter { it.index % 2 == 1 }
  val seeds = if (maxScore(evens) >= maxScore(odds)) evens else odds
  val indexes = elementsForMaxScore(seeds).map { it.index }
  // println(indexes)
  // 0-index
  val operations = mutableListOf<Int>()
  if (indexes[0] > 0) {
    repeat(indexes[0]) { operations.add(0) }
  }
  for (i in 0 until indexes.size - 1) {
    val gap = indexes[i + 1] - indexes[i]
    assert(gap % 2 == 0)
    if (gap == 2) {
      operations.add(1)
    } else {
      repeat(gap / 2 - 1) { operations.add(2) }
      operations.add(1)
    }
  }
  if (n - indexes[indexes.size - 1] - 1 > 0) {
    val remaining = n - indexes[indexes.size - 1] - 1
    // println("remaining: $remaining")
    // println(operations)
    operations.addAll(remaining downTo 1)
    // println(operations)
  }
  println(maxScore(seeds))
  println(operations.size)
  operations.forEach { println(it + 1) }
}
