This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.Polycarp likes to play computer role-playing game «Lizards and Basements». At the moment he is playing it as a magician. At one of the last levels he has to fight the line of archers. The only spell with which he can damage them is a fire ball. If Polycarp hits the i-th archer with his fire ball (they are numbered from left to right), the archer loses a health points. At the same time the spell damages the archers adjacent to the i-th (if any) — they lose b (1 ≤ b < a ≤ 10) health points each.As the extreme archers (i.e. archers numbered 1 and n) are very far, the fire ball cannot reach them. Polycarp can hit any other archer with his fire ball.The amount of health points for each archer is known. An archer will be killed when this amount is less than 0. What is the minimum amount of spells Polycarp can use to kill all the enemies?Polycarp can throw his fire ball into an archer if the latter is already killed.

The first line of the input contains three integers n, a, b (3 ≤ n ≤ 10; 1 ≤ b < a ≤ 10). The second line contains a sequence of n integers — h1, h2, ..., hn (1 ≤ hi ≤ 15), where hi is the amount of health points the i-th archer has.

In the first line print t — the required minimum amount of fire balls. In the second line print t numbers — indexes of the archers that Polycarp should hit to kill all the archers in t shots. All these numbers should be between 2 and n - 1. Separate numbers with spaces. If there are several solutions, output any of them. Print numbers in any order.

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

var n, a, b int

var best = 999999
var ans []int

func getCount(health, damage int) int {
	if health%damage == 0 {
		return health / damage
	} else {
		return (health / damage) + 1
	}
}

func dfs(layer int, h []int, solution []int, slen int) {
	if slen >= best {
		return
	}

	if len(h) == 2 {
		ca, cb := getCount(h[0], a), getCount(h[1], b)
		if ca < cb {
			ca = cb
		}
		if slen+ca < best {
			best = slen + ca
			ans = make([]int, best)
			for i := 0; i < slen; i++ {
				ans[i] = solution[i]
			}
			for i := 0; i < ca; i++ {
				ans[slen+i] = layer + 1
			}
		}
		return
	}

	count0 := getCount(h[0], b)
	count1 := getCount(h[1], a)
	count2 := getCount(h[2], b)

	for i := count0; true; i++ {
		h0, h1, h2 := h[0], h[1], h[2]

		h[0] = 0
		if h1 >= a*i {
			h[1] = h1 - a*i
		} else {
			h[1] = 0
		}
		if h2 >= b*i {
			h[2] = h2 - b*i
		} else {
			h[2] = 0
		}
		for j := 0; j < i; j++ {
			solution[slen+j] = layer + 2
		}
		dfs(layer+1, h[1:], solution, slen+i)

		h[0], h[1], h[2] = h0, h1, h2
		if i > count0 && i > count1 && i > count2 {
			break
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	fmt.Fscanf(reader, "%d %d %d\n", &n, &a, &b)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d ", &h[i])
		h[i]++
	}
	dfs(0, h, make([]int, 128, 128), 0)
	fmt.Printf("%d\n", best)
	for i := 0; i < best; i++ {
		fmt.Printf("%d ", ans[i])
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, a, b := readThreeNums(reader)

	h := readNNums(reader, n)

	res := solve(n, a, b, h)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	fmt.Println(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 10000

func solve(n int, a int, b int, h []int) []int {
	for i := 0; i < n; i++ {
		h[i]++
	}
	if n == 3 {
		var res []int
		for h[0] > 0 || h[1] > 0 || h[2] > 0 {
			h[0] = max(0, h[0]-b)
			h[1] = max(0, h[1]-a)
			h[2] = max(0, h[2]-b)
			res = append(res, 2)
		}
		return res
	}
	dp := make([][][]int, n)
	num := make([][][]int, n)
	hlh := make([][][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([][]int, h[i]+1)
		num[i] = make([][]int, h[i]+1)
		hlh[i] = make([][]int, h[i]+1)
		for j := 0; j <= h[i]; j++ {
			num[i][j] = make([]int, 20)
			dp[i][j] = make([]int, 20)
			hlh[i][j] = make([]int, 20)
			for k := 0; k < len(dp[i][j]); k++ {
				dp[i][j][k] = INF
			}
		}
	}
	dp[0][h[0]][0] = 0
	num[0][h[0]][0] = 0
	hlh[0][h[0]][0] = h[0]

	for i := 1; i < n-1; i++ {
		for j := 0; j <= h[i-1]; j++ {
			for k := 0; k < len(dp[i-1][j]); k++ {
				if dp[i-1][j][k] >= INF {
					continue
				}
				//first: need to make sure attacks at this archer can make h[i-1] to be zero
				for kk := 0; kk < 20; kk++ {
					jj := max(0, h[i]-b*k-a*kk)
					if kk*b >= j {
						if dp[i][jj][kk] > dp[i-1][j][k]+kk {
							dp[i][jj][kk] = dp[i-1][j][k] + kk
							num[i][jj][kk] = k
							hlh[i][jj][kk] = j
						}
					}
				}
			}
		}
	}

	for j := 0; j <= h[n-2]; j++ {
		for k := 0; k < len(dp[n-2][j]); k++ {
			if dp[n-2][j][k] >= INF {
				continue
			}
			if k*b >= h[n-1] {
				if dp[n-1][0][0] > dp[n-2][j][k] {
					dp[n-1][0][0] = dp[n-2][j][k]
					num[n-1][0][0] = k
					hlh[n-1][0][0] = j
				}
			}
		}
	}
	best := dp[n-1][0][0]
	res := make([]int, 0, best)
	ii := n - 1
	jj := 0
	kk := 0
	for best > 0 {
		k := num[ii][jj][kk]
		j := hlh[ii][jj][kk]
		x := dp[ii][jj][kk] - dp[ii-1][j][k]
		for x > 0 {
			res = append(res, ii+1)
			x--
			best--
		}
		ii--
		jj, kk = j, k
	}

	return res
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, a, b := readThreeNums(reader)

	h := readNNums(reader, n)

	res := solve(n, a, b, h)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	fmt.Println(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 10000

func solve(n int, a int, b int, h []int) []int {
	for i := 0; i < n; i++ {
		h[i]++
	}
	dp := make([][][]int, n)
	num := make([][][]int, n)
	hlh := make([][][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([][]int, h[i]+1)
		num[i] = make([][]int, h[i]+1)
		hlh[i] = make([][]int, h[i]+1)
		for j := 0; j <= h[i]; j++ {
			num[i][j] = make([]int, 20)
			dp[i][j] = make([]int, 20)
			hlh[i][j] = make([]int, 20)
			for k := 0; k < len(dp[i][j]); k++ {
				dp[i][j][k] = INF
			}
		}
	}
	dp[0][h[0]][0] = 0
	num[0][h[0]][0] = 0
	hlh[0][h[0]][0] = h[0]

	for i := 1; i < n-1; i++ {
		for j := 0; j <= h[i-1]; j++ {
			for k := 0; k < len(dp[i-1][j]); k++ {
				if dp[i-1][j][k] >= INF {
					continue
				}
				//first: need to make sure attacks at this archer can make h[i-1] to be zero
				for kk := 0; kk < 20; kk++ {
					jj := max(0, h[i]-b*k-a*kk)
					if kk*b >= j {
						if dp[i][jj][kk] > dp[i-1][j][k]+kk {
							dp[i][jj][kk] = dp[i-1][j][k] + kk
							num[i][jj][kk] = k
							hlh[i][jj][kk] = j
						}
					}
				}
			}
		}
	}

	for j := 0; j <= h[n-2]; j++ {
		for k := 0; k < len(dp[n-2][j]); k++ {
			if dp[n-2][j][k] >= INF {
				continue
			}
			if k*b >= h[n-1] {
				if dp[n-1][0][0] > dp[n-2][j][k] {
					dp[n-1][0][0] = dp[n-2][j][k]
					num[n-1][0][0] = k
					hlh[n-1][0][0] = j
				}
			}
		}
	}
	best := dp[n-1][0][0]
	res := make([]int, 0, best)
	ii := n - 1
	jj := 0
	kk := 0
	for best > 0 {
		k := num[ii][jj][kk]
		j := hlh[ii][jj][kk]
		x := dp[ii][jj][kk] - dp[ii-1][j][k]
		for x > 0 {
			res = append(res, ii+1)
			x--
			best--
		}
		ii--
		jj, kk = j, k
	}

	return res
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, a, b := readThreeNums(reader)

	h := readNNums(reader, n)

	res := solve(n, a, b, h)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	fmt.Println(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 10000

func solve(n int, a int, b int, h []int) []int {
	for i := 0; i < n; i++ {
		h[i]++
	}
	dp := make([][][]int, n)
	num := make([][][]int, n)
	hlh := make([][][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([][]int, h[i]+1)
		num[i] = make([][]int, h[i]+1)
		hlh[i] = make([][]int, h[i]+1)
		for j := 0; j <= h[i]; j++ {
			num[i][j] = make([]int, 20)
			dp[i][j] = make([]int, 20)
			hlh[i][j] = make([]int, 20)
			for k := 0; k < len(dp[i][j]); k++ {
				dp[i][j][k] = INF
			}
		}
	}
	dp[0][h[0]][0] = 0
	num[0][h[0]][0] = 0
	hlh[0][h[0]][0] = h[0]

	for i := 1; i < n-1; i++ {
		for j := 0; j <= h[i-1]; j++ {
			for k := 0; k < len(dp[i-1][j]); k++ {
				if dp[i-1][j][k] >= INF {
					continue
				}
				//first: need to make sure attacks at this archer can make h[i-1] to be zero
				for kk := 0; kk < 20; kk++ {
					jj := max(0, h[i]-b*k-a*kk)
					if kk*b >= j {
						if dp[i][jj][kk] > dp[i-1][j][k]+kk {
							dp[i][jj][kk] = dp[i-1][j][k] + kk
							num[i][jj][kk] = k
							hlh[i][jj][kk] = j
						}
					}
				}
			}
		}
	}

	for j := 0; j <= h[n-2]; j++ {
		for k := 0; k < len(dp[n-2][j]); k++ {
			if dp[n-2][j][k] >= INF {
				continue
			}
			if k*b >= h[n-1] {
				if dp[n-1][0][0] > dp[n-2][j][k] {
					dp[n-1][0][0] = dp[n-2][j][k]
					num[n-1][0][0] = k
					hlh[n-1][0][0] = j
				}
			}
		}
	}
	best := dp[n-1][0][0]
	res := make([]int, 0, best)
	ii := n - 1
	jj := 0
	kk := 0
	for best > 0 {
		k := num[ii][jj][kk]
		j := hlh[ii][jj][kk]
		//x := dp[ii][jj][kk] - dp[ii-1][j][k]
		for x := 0; x < k; x++ {
			res = append(res, ii)
		}
		best -= k
		ii--
		jj, kk = j, k
	}

	return res
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

package main

import (
	"strings"
	"fmt"
	"strconv"
	"errors"
	"io"
	"unicode/utf8"
	"bytes"
	"os"
	"runtime"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func solve(i int, hp_ []int, order_ []int, a, b int, s string) []int {
	hp := make([]int, len(hp_))
	copy(hp, hp_)
	order := make([]int, len(order_))
	copy(order, order_)
	if i <= 4 {
		defer runtime.GC()
	}
	if i >= len(hp) - 1 {
		return order
	}

	for hp[i - 1] > 0 {
		hp[i - 1], hp[i], hp[i + 1] = hp[i - 1] - min(hp[i - 1], b), hp[i] - min(hp[i], a), hp[i + 1] - min(hp[i + 1], b)
		order = append(order, i + 1)
	}

	best := solve(i + 1, hp, order, a, b, s + " ")

	for hp[i] > 0 || hp[i + 1] > 0 {
		hp[i - 1], hp[i], hp[i + 1] = hp[i - 1] - min(hp[i - 1], b), hp[i] - min(hp[i], a), hp[i + 1] - min(hp[i + 1], b)
		order = append(order, i + 1)
		temp := solve(i + 1, hp, order, a, b, s + " ")
		if len(temp) < len(best) {
			best = temp
		}
	}
	return best
}

func main() {
	//defer func() {
	//	if r := recover(); r != nil {
	//		fmt.Println("error: ", r)
	//	}
	//}()
	n, a, b := nextInt(), nextInt(), nextInt()
	hp := make([]int, n)
	for i := 0; i < n; i++ {
		hp[i] = nextInt() + 1
	}
	order := make([]int, 0)
	for hp[0] > 0 {
		order = append(order, 2)
		hp[0], hp[1], hp[2] = hp[0] - min(hp[0], b), hp[1] - min(hp[1], a), hp[2] - min(hp[2], b)
	}
	for hp[n - 1] > 0 {
		order = append(order, n - 1)
		hp[n - 1], hp[n - 2], hp[n - 3] = hp[n - 1] - min(hp[n - 1], b), hp[n - 2] - min(hp[n - 2], a), hp[n - 3] - min(hp[n - 3], b)
	}
	order = solve(1, hp, order, a, b, "")
	res := fmt.Sprintf("%v", order)
	res = res[1:len(res)-1]
	printf("%d\n%s\n", len(order), res)
}

var lineScanner *Scanner
var wordScanner *Scanner

func init() {
	lineScanner = NewScanner(os.Stdin)
	wordScanner = NewScanner(strings.NewReader(""))
	wordScanner.Split(ScanWords)
}

func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = NewScanner(strings.NewReader(line))
		wordScanner.Split(ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

// Scanner provides a convenient interface for reading data such as
// a file of newline-delimited lines of text. Successive calls to
// the Scan method will step through the 'tokens' of a file, skipping
// the bytes between the tokens. The specification of a token is
// defined by a split function of type SplitFunc; the default split
// function breaks the input into lines with line termination stripped. Split
// functions are defined in this package for scanning a file into
// lines, bytes, UTF-8-encoded runes, and space-delimited words. The
// client may instead provide a custom split function.
//
// Scanning stops unrecoverably at EOF, the first I/O error, or a token too
// large to fit in the buffer. When a scan stops, the reader may have
// advanced arbitrarily far past the last token. Programs that need more
// control over error handling or large tokens, or must run sequential scans
// on a reader, should use bufio.Reader instead.
//
type Scanner struct {
	r            io.Reader // The reader provided by the client.
	split        SplitFunc // The function to split the tokens.
	maxTokenSize int       // Maximum size of a token; modified by tests.
	token        []byte    // Last token returned by split.
	buf          []byte    // Buffer used as argument to split.
	start        int       // First non-processed byte in buf.
	end          int       // End of data in buf.
	err          error     // Sticky error.
	empties      int       // Count of successive empty tokens.
	scanCalled   bool      // Scan has been called; buffer is in use.
	done         bool      // Scan has finished.
}

// SplitFunc is the signature of the split function used to tokenize the
// input. The arguments are an initial substring of the remaining unprocessed
// data and a flag, atEOF, that reports whether the Reader has no more data
// to give. The return values are the number of bytes to advance the input
// and the next token to return to the user, plus an error, if any. If the
// data does not yet hold a complete token, for instance if it has no newline
// while scanning lines, SplitFunc can return (0, nil, nil) to signal the
// Scanner to read more data into the slice and try again with a longer slice
// starting at the same point in the input.
//
// If the returned error is non-nil, scanning stops and the error
// is returned to the client.
//
// The function is never called with an empty data slice unless atEOF
// is true. If atEOF is true, however, data may be non-empty and,
// as always, holds unprocessed text.
type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)

// Errors returned by Scanner.
var (
	ErrTooLong = errors.New("bufio.Scanner: token too long")
	ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count")
	ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input")
)

const (
// MaxScanTokenSize is the maximum size used to buffer a token
// unless the user provides an explicit buffer with Scan.Buffer.
// The actual maximum token size may be smaller as the buffer
// may need to include, for instance, a newline.
	MaxScanTokenSize = 2 * 1024 * 2014

	startBufSize = 4096 // Size of initial allocation for buffer.
)

// NewScanner returns a new Scanner to read from r.
// The split function defaults to ScanLines.
func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        ScanLines,
		maxTokenSize: MaxScanTokenSize,
	}
}

// Err returns the first non-EOF error that was encountered by the Scanner.
func (s *Scanner) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}

// Bytes returns the most recent token generated by a call to Scan.
// The underlying array may point to data that will be overwritten
// by a subsequent call to Scan. It does no allocation.
func (s *Scanner) Bytes() []byte {
	return s.token
}

// Text returns the most recent token generated by a call to Scan
// as a newly allocated string holding its bytes.
func (s *Scanner) Text() string {
	return string(s.token)
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the Scanner to the next token, which will then be
// available through the Bytes or Text method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
// Scan panics if the split function returns 100 empty tokens without
// advancing the input. This is a common error mode for scanners.
func (s *Scanner) Scan() bool {
	if s.done {
		return false
	}
	s.scanCalled = true
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		// If we've run out of data but have an error, give the split function
		// a chance to recover any remaining, possibly empty token.
		if s.end > s.start || s.err != nil {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				if err == ErrFinalToken {
					s.token = token
					s.done = true
					return true
				}
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				if s.err == nil || advance > 0 {
					s.empties = 0
				} else {
					// Returning tokens not advancing input at EOF.
					s.empties++
					if s.empties > 100 {
						panic("bufio.Scan: 100 empty tokens without progressing")
					}
				}
				return true
			}
		}
		// We cannot generate a token with what we are holding.
		// If we've already hit EOF or an I/O error, we are done.
		if s.err != nil {
			// Shut it down.
			s.start = 0
			s.end = 0
			return false
		}
		// Must read more data.
		// First, shift data to beginning of buffer if there's lots of empty space
		// or space is needed.
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		// Is the buffer full? If so, resize.
		if s.end == len(s.buf) {
			// Guarantee no overflow in the multiplication below.
			const maxInt = int(^uint(0) >> 1)
			if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			if newSize == 0 {
				newSize = startBufSize
			}
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		// Finally we can read some input. Make sure we don't get stuck with
		// a misbehaving Reader. Officially we don't need to do this, but let's
		// be extra careful: Scanner is for safe, simple jobs.
		for loop := 0;; {
			n, err := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if err != nil {
				s.setErr(err)
				break
			}
			if n > 0 {
				s.empties = 0
				break
			}
			loop++
			if loop > 10 {
				s.setErr(io.ErrNoProgress)
				break
			}
		}
	}
}

// advance consumes n bytes of the buffer. It reports whether the advance was legal.
func (s *Scanner) advance(n int) bool {
	if n < 0 {
		s.setErr(ErrNegativeAdvance)
		return false
	}
	if n > s.end - s.start {
		s.setErr(ErrAdvanceTooFar)
		return false
	}
	s.start += n
	return true
}

// setErr records the first error encountered.
func (s *Scanner) setErr(err error) {
	if s.err == nil || s.err == io.EOF {
		s.err = err
	}
}

// Buffer sets the initial buffer to use when scanning and the maximum
// size of buffer that may be allocated during scanning. The maximum
// token size is the larger of max and cap(buf). If max <= cap(buf),
// Scan will use this buffer only and do no allocation.
//
// By default, Scan uses an internal buffer and sets the
// maximum token size to MaxScanTokenSize.
//
// Buffer panics if it is called after scanning has started.
func (s *Scanner) Buffer(buf []byte, max int) {
	if s.scanCalled {
		panic("Buffer called after Scan")
	}
	s.buf = buf[0:cap(buf)]
	s.maxTokenSize = max
}

// Split sets the split function for the Scanner.
// The default split function is ScanLines.
//
// Split panics if it is called after scanning has started.
func (s *Scanner) Split(split SplitFunc) {
	if s.scanCalled {
		panic("Split called after Scan")
	}
	s.split = split
}

// Split functions

// ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	return 1, data[0:1], nil
}

var errorRune = []byte(string(utf8.RuneError))

// ScanRunes is a split function for a Scanner that returns each
// UTF-8-encoded rune as a token. The sequence of runes returned is
// equivalent to that from a range loop over the input as a string, which
// means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd".
// Because of the Scan interface, this makes it impossible for the client to
// distinguish correctly encoded replacement runes from encoding errors.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}

	// Fast path 1: ASCII.
	if data[0] < utf8.RuneSelf {
		return 1, data[0:1], nil
	}

	// Fast path 2: Correct UTF-8 decode without error.
	_, width := utf8.DecodeRune(data)
	if width > 1 {
		// It's a valid encoding. Width cannot be one for a correctly encoded
		// non-ASCII rune.
		return width, data[0:width], nil
	}

	// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.
	// Is the error because there wasn't a full rune to be decoded?
	// FullRune distinguishes correctly between erroneous and incomplete encodings.
	if !atEOF && !utf8.FullRune(data) {
		// Incomplete; get more bytes.
		return 0, nil, nil
	}

	// We have a real UTF-8 encoding error. Return a properly encoded error rune
	// but advance only one byte. This matches the behavior of a range loop over
	// an incorrectly encoded string.
	return 1, errorRune, nil
}

// dropCR drops a terminal \r from the data.
func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data) - 1] == '\r' {
		return data[0 : len(data) - 1]
	}
	return data
}

// ScanLines is a split function for a Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one optional carriage return followed
// by one mandatory newline. In regular expression notation, it is `\r?\n`.
// The last non-empty line of input will be returned even if it has no
// newline.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		// We have a full newline-terminated line.
		return i + 1, dropCR(data[0:i]), nil
	}
	// If we're at EOF, we have a final, non-terminated line. Return it.
	if atEOF {
		return len(data), dropCR(data), nil
	}
	// Request more data.
	return 0, nil, nil
}

// isSpace reports whether the character is a Unicode white space character.
// We avoid dependency on the unicode package, but check validity of the implementation
// in the tests.
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

// ScanWords is a split function for a Scanner that returns each
// space-separated word of text, with surrounding spaces deleted. It will
// never return an empty string. The definition of space is set by
// unicode.IsSpace.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return start, nil, nil
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, a, b := readThreeNums(reader)

	h := readNNums(reader, n)

	res := solve(n, a, b, h)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	fmt.Println(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 10000

func solve(n int, a int, b int, h []int) []int {
	for i := 0; i < n; i++ {
		h[i]++
	}
	if n == 3 {
		var res []int
		for h[0] > 0 || h[1] > 0 || h[2] > 0 {
			h[0] = max(0, h[0]-b)
			h[1] = max(0, h[1]-a)
			h[2] = max(0, h[2]-b)
			res = append(res, 2)
		}
		return res
	}
	dp := make([][][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([][]int, h[i]+1)
		for j := 0; j <= h[i]; j++ {
			dp[i][j] = make([]int, 20)
			for k := 0; k < len(dp[i][j]); k++ {
				dp[i][j][k] = INF
			}
		}
	}
	dp[0][h[0]][0] = 0

	for i := 1; i < n-1; i++ {
		for j := 0; j <= h[i-1]; j++ {
			for k := 0; k < len(dp[i-1][j]); k++ {
				if dp[i-1][j][k] >= INF {
					continue
				}
				//first: need to make sure attacks at this archer can make h[i-1] to be zero
				for kk := 0; kk < 20; kk++ {
					jj := max(0, h[i]-b*k-a*kk)
					if kk*b >= j {
						dp[i][jj][kk] = min(dp[i][jj][kk], dp[i-1][j][k]+kk)
					}
				}
			}
		}
	}

	for j := 0; j <= h[n-2]; j++ {
		for k := 0; k < len(dp[n-2][j]); k++ {
			if dp[n-2][j][k] >= INF {
				continue
			}
			if k*b >= h[n-1] {
				dp[n-1][0][0] = min(dp[n-1][0][0], dp[n-2][j][k])
			}
		}
	}
	best := dp[n-1][0][0]
	res := make([]int, 0, best)

	for i := n - 2; i > 0; i-- {
		var found = false
		for j := 0; j <= h[i] && !found; j++ {
			for k := 0; k < len(dp[i][j]) && !found; k++ {
				if dp[i][j][k] == best {
					for x := 0; x < k; x++ {
						res = append(res, i+1)
					}
					best -= k
					found = true
				}
			}
		}
	}

	return res
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

package main

import (
	"strings"
	"fmt"
	"strconv"
	"errors"
	"io"
	"unicode/utf8"
	"bytes"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
func main() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("error: ", r)
		}
	}()
	n, a, b := nextInt(), nextInt(), nextInt()
	hp := make([]int, n)
	totalHp := 0
	for i := 0; i < n; i++ {
		hp[i] = nextInt() + 1
		totalHp += hp[i]
	}
	order := make([]int, 0)
	for hp[0] > 0 {
		order = append(order, 2)
		totalHp -= min(hp[0], b) + min(hp[1], a) + min(hp[2], b)
		hp[0], hp[1], hp[2] = hp[0] - min(hp[0], b), hp[1] - min(hp[1], a), hp[2] - min(hp[2], b)
	}
	for hp[n - 1] > 0 {
		order = append(order, n - 1)
		totalHp -= min(hp[n - 1], b) + min(hp[n - 2], a) + min(hp[n - 3], b)
		hp[n - 1], hp[n - 2], hp[n - 3] = hp[n - 1] - min(hp[n - 1], b), hp[n - 2] - min(hp[n - 2], a), hp[n - 3] - min(hp[n - 3], b)
	}
	for totalHp > 0 {
		maxDmg := 0
		hit := 0
		for i := 1; i < n - 1; i++ {
			curDmg := min(hp[i - 1], b) + min(hp[i], a) + min(hp[i + 1], b)
			if maxDmg < curDmg {
				maxDmg = curDmg
				hit = i
			}
		}
		order = append(order, hit + 1)
		totalHp -= maxDmg
		hp[hit - 1], hp[hit], hp[hit + 1] = hp[hit - 1] - min(hp[hit - 1], b), hp[hit] - min(hp[hit], a), hp[hit + 1] - min(hp[hit + 1], b)
	}
	res := fmt.Sprintf("%v", order)
	res = res[1:len(res)-1]
	printf("%d\n%s\n", len(order), res)
}

var lineScanner *Scanner
var wordScanner *Scanner

func init() {
	lineScanner = NewScanner(os.Stdin)
	wordScanner = NewScanner(strings.NewReader(""))
	wordScanner.Split(ScanWords)
}

func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = NewScanner(strings.NewReader(line))
		wordScanner.Split(ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

// Scanner provides a convenient interface for reading data such as
// a file of newline-delimited lines of text. Successive calls to
// the Scan method will step through the 'tokens' of a file, skipping
// the bytes between the tokens. The specification of a token is
// defined by a split function of type SplitFunc; the default split
// function breaks the input into lines with line termination stripped. Split
// functions are defined in this package for scanning a file into
// lines, bytes, UTF-8-encoded runes, and space-delimited words. The
// client may instead provide a custom split function.
//
// Scanning stops unrecoverably at EOF, the first I/O error, or a token too
// large to fit in the buffer. When a scan stops, the reader may have
// advanced arbitrarily far past the last token. Programs that need more
// control over error handling or large tokens, or must run sequential scans
// on a reader, should use bufio.Reader instead.
//
type Scanner struct {
	r            io.Reader // The reader provided by the client.
	split        SplitFunc // The function to split the tokens.
	maxTokenSize int       // Maximum size of a token; modified by tests.
	token        []byte    // Last token returned by split.
	buf          []byte    // Buffer used as argument to split.
	start        int       // First non-processed byte in buf.
	end          int       // End of data in buf.
	err          error     // Sticky error.
	empties      int       // Count of successive empty tokens.
	scanCalled   bool      // Scan has been called; buffer is in use.
	done         bool      // Scan has finished.
}

// SplitFunc is the signature of the split function used to tokenize the
// input. The arguments are an initial substring of the remaining unprocessed
// data and a flag, atEOF, that reports whether the Reader has no more data
// to give. The return values are the number of bytes to advance the input
// and the next token to return to the user, plus an error, if any. If the
// data does not yet hold a complete token, for instance if it has no newline
// while scanning lines, SplitFunc can return (0, nil, nil) to signal the
// Scanner to read more data into the slice and try again with a longer slice
// starting at the same point in the input.
//
// If the returned error is non-nil, scanning stops and the error
// is returned to the client.
//
// The function is never called with an empty data slice unless atEOF
// is true. If atEOF is true, however, data may be non-empty and,
// as always, holds unprocessed text.
type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)

// Errors returned by Scanner.
var (
	ErrTooLong = errors.New("bufio.Scanner: token too long")
	ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count")
	ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input")
)

const (
// MaxScanTokenSize is the maximum size used to buffer a token
// unless the user provides an explicit buffer with Scan.Buffer.
// The actual maximum token size may be smaller as the buffer
// may need to include, for instance, a newline.
	MaxScanTokenSize = 2 * 1024 * 2014

	startBufSize = 4096 // Size of initial allocation for buffer.
)

// NewScanner returns a new Scanner to read from r.
// The split function defaults to ScanLines.
func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        ScanLines,
		maxTokenSize: MaxScanTokenSize,
	}
}

// Err returns the first non-EOF error that was encountered by the Scanner.
func (s *Scanner) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}

// Bytes returns the most recent token generated by a call to Scan.
// The underlying array may point to data that will be overwritten
// by a subsequent call to Scan. It does no allocation.
func (s *Scanner) Bytes() []byte {
	return s.token
}

// Text returns the most recent token generated by a call to Scan
// as a newly allocated string holding its bytes.
func (s *Scanner) Text() string {
	return string(s.token)
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the Scanner to the next token, which will then be
// available through the Bytes or Text method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
// Scan panics if the split function returns 100 empty tokens without
// advancing the input. This is a common error mode for scanners.
func (s *Scanner) Scan() bool {
	if s.done {
		return false
	}
	s.scanCalled = true
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		// If we've run out of data but have an error, give the split function
		// a chance to recover any remaining, possibly empty token.
		if s.end > s.start || s.err != nil {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				if err == ErrFinalToken {
					s.token = token
					s.done = true
					return true
				}
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				if s.err == nil || advance > 0 {
					s.empties = 0
				} else {
					// Returning tokens not advancing input at EOF.
					s.empties++
					if s.empties > 100 {
						panic("bufio.Scan: 100 empty tokens without progressing")
					}
				}
				return true
			}
		}
		// We cannot generate a token with what we are holding.
		// If we've already hit EOF or an I/O error, we are done.
		if s.err != nil {
			// Shut it down.
			s.start = 0
			s.end = 0
			return false
		}
		// Must read more data.
		// First, shift data to beginning of buffer if there's lots of empty space
		// or space is needed.
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		// Is the buffer full? If so, resize.
		if s.end == len(s.buf) {
			// Guarantee no overflow in the multiplication below.
			const maxInt = int(^uint(0) >> 1)
			if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			if newSize == 0 {
				newSize = startBufSize
			}
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		// Finally we can read some input. Make sure we don't get stuck with
		// a misbehaving Reader. Officially we don't need to do this, but let's
		// be extra careful: Scanner is for safe, simple jobs.
		for loop := 0;; {
			n, err := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if err != nil {
				s.setErr(err)
				break
			}
			if n > 0 {
				s.empties = 0
				break
			}
			loop++
			if loop > 10 {
				s.setErr(io.ErrNoProgress)
				break
			}
		}
	}
}

// advance consumes n bytes of the buffer. It reports whether the advance was legal.
func (s *Scanner) advance(n int) bool {
	if n < 0 {
		s.setErr(ErrNegativeAdvance)
		return false
	}
	if n > s.end - s.start {
		s.setErr(ErrAdvanceTooFar)
		return false
	}
	s.start += n
	return true
}

// setErr records the first error encountered.
func (s *Scanner) setErr(err error) {
	if s.err == nil || s.err == io.EOF {
		s.err = err
	}
}

// Buffer sets the initial buffer to use when scanning and the maximum
// size of buffer that may be allocated during scanning. The maximum
// token size is the larger of max and cap(buf). If max <= cap(buf),
// Scan will use this buffer only and do no allocation.
//
// By default, Scan uses an internal buffer and sets the
// maximum token size to MaxScanTokenSize.
//
// Buffer panics if it is called after scanning has started.
func (s *Scanner) Buffer(buf []byte, max int) {
	if s.scanCalled {
		panic("Buffer called after Scan")
	}
	s.buf = buf[0:cap(buf)]
	s.maxTokenSize = max
}

// Split sets the split function for the Scanner.
// The default split function is ScanLines.
//
// Split panics if it is called after scanning has started.
func (s *Scanner) Split(split SplitFunc) {
	if s.scanCalled {
		panic("Split called after Scan")
	}
	s.split = split
}

// Split functions

// ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	return 1, data[0:1], nil
}

var errorRune = []byte(string(utf8.RuneError))

// ScanRunes is a split function for a Scanner that returns each
// UTF-8-encoded rune as a token. The sequence of runes returned is
// equivalent to that from a range loop over the input as a string, which
// means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd".
// Because of the Scan interface, this makes it impossible for the client to
// distinguish correctly encoded replacement runes from encoding errors.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}

	// Fast path 1: ASCII.
	if data[0] < utf8.RuneSelf {
		return 1, data[0:1], nil
	}

	// Fast path 2: Correct UTF-8 decode without error.
	_, width := utf8.DecodeRune(data)
	if width > 1 {
		// It's a valid encoding. Width cannot be one for a correctly encoded
		// non-ASCII rune.
		return width, data[0:width], nil
	}

	// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.
	// Is the error because there wasn't a full rune to be decoded?
	// FullRune distinguishes correctly between erroneous and incomplete encodings.
	if !atEOF && !utf8.FullRune(data) {
		// Incomplete; get more bytes.
		return 0, nil, nil
	}

	// We have a real UTF-8 encoding error. Return a properly encoded error rune
	// but advance only one byte. This matches the behavior of a range loop over
	// an incorrectly encoded string.
	return 1, errorRune, nil
}

// dropCR drops a terminal \r from the data.
func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data) - 1] == '\r' {
		return data[0 : len(data) - 1]
	}
	return data
}

// ScanLines is a split function for a Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one optional carriage return followed
// by one mandatory newline. In regular expression notation, it is `\r?\n`.
// The last non-empty line of input will be returned even if it has no
// newline.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		// We have a full newline-terminated line.
		return i + 1, dropCR(data[0:i]), nil
	}
	// If we're at EOF, we have a final, non-terminated line. Return it.
	if atEOF {
		return len(data), dropCR(data), nil
	}
	// Request more data.
	return 0, nil, nil
}

// isSpace reports whether the character is a Unicode white space character.
// We avoid dependency on the unicode package, but check validity of the implementation
// in the tests.
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

// ScanWords is a split function for a Scanner that returns each
// space-separated word of text, with surrounding spaces deleted. It will
// never return an empty string. The definition of space is set by
// unicode.IsSpace.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return start, nil, nil
}

package main

import (
	"strings"
	"fmt"
	"strconv"
	"errors"
	"io"
	"unicode/utf8"
	"bytes"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
func main() {
	//defer func() {
	//	if r := recover(); r != nil {
	//		fmt.Println("error: ", r)
	//	}
	//}()
	n, a, b := nextInt(), nextInt(), nextInt()
	hp := make([]int, n)
	totalHp := 0
	for i := 0; i < n; i++ {
		hp[i] = nextInt() + 1
		totalHp += hp[i]
	}
	order := make([]int, 0)
	for hp[0] > 0 {
		order = append(order, 2)
		totalHp -= min(hp[0], b) + min(hp[1], a) + min(hp[2], b)
		hp[0], hp[1], hp[2] = hp[0] - min(hp[0], b), hp[1] - min(hp[1], a), hp[2] - min(hp[2], b)
	}
	for hp[n - 1] > 0 {
		order = append(order, n - 1)
		totalHp -= min(hp[n - 1], b) + min(hp[n - 2], a) + min(hp[n - 3], b)
		hp[n - 1], hp[n - 2], hp[n - 3] = hp[n - 1] - min(hp[n - 1], b), hp[n - 2] - min(hp[n - 2], a), hp[n - 3] - min(hp[n - 3], b)
	}
	for totalHp > 0 {
		maxDmg := 0
		hit := 0
		for i := 1; i < n - 1; i++ {
			//curDmg := min(hp[i - 1], b) + min(hp[i], a) + min(hp[i + 1], b)
			curDmg := hp[i]//min(hp[i], a)
			if maxDmg < curDmg {
				maxDmg = curDmg
				hit = i
			}
		}
		order = append(order, hit + 1)
		totalHp -= min(hp[hit - 1], b) + min(hp[hit], a) + min(hp[hit + 1], b)
		hp[hit - 1], hp[hit], hp[hit + 1] = hp[hit - 1] - min(hp[hit - 1], b), hp[hit] - min(hp[hit], a), hp[hit + 1] - min(hp[hit + 1], b)
	}
	res := fmt.Sprintf("%v", order)
	res = res[1:len(res)-1]
	printf("%d\n%s\n", len(order), res)
}

var lineScanner *Scanner
var wordScanner *Scanner

func init() {
	lineScanner = NewScanner(os.Stdin)
	wordScanner = NewScanner(strings.NewReader(""))
	wordScanner.Split(ScanWords)
}

func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = NewScanner(strings.NewReader(line))
		wordScanner.Split(ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

// Scanner provides a convenient interface for reading data such as
// a file of newline-delimited lines of text. Successive calls to
// the Scan method will step through the 'tokens' of a file, skipping
// the bytes between the tokens. The specification of a token is
// defined by a split function of type SplitFunc; the default split
// function breaks the input into lines with line termination stripped. Split
// functions are defined in this package for scanning a file into
// lines, bytes, UTF-8-encoded runes, and space-delimited words. The
// client may instead provide a custom split function.
//
// Scanning stops unrecoverably at EOF, the first I/O error, or a token too
// large to fit in the buffer. When a scan stops, the reader may have
// advanced arbitrarily far past the last token. Programs that need more
// control over error handling or large tokens, or must run sequential scans
// on a reader, should use bufio.Reader instead.
//
type Scanner struct {
	r            io.Reader // The reader provided by the client.
	split        SplitFunc // The function to split the tokens.
	maxTokenSize int       // Maximum size of a token; modified by tests.
	token        []byte    // Last token returned by split.
	buf          []byte    // Buffer used as argument to split.
	start        int       // First non-processed byte in buf.
	end          int       // End of data in buf.
	err          error     // Sticky error.
	empties      int       // Count of successive empty tokens.
	scanCalled   bool      // Scan has been called; buffer is in use.
	done         bool      // Scan has finished.
}

// SplitFunc is the signature of the split function used to tokenize the
// input. The arguments are an initial substring of the remaining unprocessed
// data and a flag, atEOF, that reports whether the Reader has no more data
// to give. The return values are the number of bytes to advance the input
// and the next token to return to the user, plus an error, if any. If the
// data does not yet hold a complete token, for instance if it has no newline
// while scanning lines, SplitFunc can return (0, nil, nil) to signal the
// Scanner to read more data into the slice and try again with a longer slice
// starting at the same point in the input.
//
// If the returned error is non-nil, scanning stops and the error
// is returned to the client.
//
// The function is never called with an empty data slice unless atEOF
// is true. If atEOF is true, however, data may be non-empty and,
// as always, holds unprocessed text.
type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)

// Errors returned by Scanner.
var (
	ErrTooLong = errors.New("bufio.Scanner: token too long")
	ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count")
	ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input")
)

const (
// MaxScanTokenSize is the maximum size used to buffer a token
// unless the user provides an explicit buffer with Scan.Buffer.
// The actual maximum token size may be smaller as the buffer
// may need to include, for instance, a newline.
	MaxScanTokenSize = 2 * 1024 * 2014

	startBufSize = 4096 // Size of initial allocation for buffer.
)

// NewScanner returns a new Scanner to read from r.
// The split function defaults to ScanLines.
func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        ScanLines,
		maxTokenSize: MaxScanTokenSize,
	}
}

// Err returns the first non-EOF error that was encountered by the Scanner.
func (s *Scanner) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}

// Bytes returns the most recent token generated by a call to Scan.
// The underlying array may point to data that will be overwritten
// by a subsequent call to Scan. It does no allocation.
func (s *Scanner) Bytes() []byte {
	return s.token
}

// Text returns the most recent token generated by a call to Scan
// as a newly allocated string holding its bytes.
func (s *Scanner) Text() string {
	return string(s.token)
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the Scanner to the next token, which will then be
// available through the Bytes or Text method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
// Scan panics if the split function returns 100 empty tokens without
// advancing the input. This is a common error mode for scanners.
func (s *Scanner) Scan() bool {
	if s.done {
		return false
	}
	s.scanCalled = true
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		// If we've run out of data but have an error, give the split function
		// a chance to recover any remaining, possibly empty token.
		if s.end > s.start || s.err != nil {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				if err == ErrFinalToken {
					s.token = token
					s.done = true
					return true
				}
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				if s.err == nil || advance > 0 {
					s.empties = 0
				} else {
					// Returning tokens not advancing input at EOF.
					s.empties++
					if s.empties > 100 {
						panic("bufio.Scan: 100 empty tokens without progressing")
					}
				}
				return true
			}
		}
		// We cannot generate a token with what we are holding.
		// If we've already hit EOF or an I/O error, we are done.
		if s.err != nil {
			// Shut it down.
			s.start = 0
			s.end = 0
			return false
		}
		// Must read more data.
		// First, shift data to beginning of buffer if there's lots of empty space
		// or space is needed.
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		// Is the buffer full? If so, resize.
		if s.end == len(s.buf) {
			// Guarantee no overflow in the multiplication below.
			const maxInt = int(^uint(0) >> 1)
			if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			if newSize == 0 {
				newSize = startBufSize
			}
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		// Finally we can read some input. Make sure we don't get stuck with
		// a misbehaving Reader. Officially we don't need to do this, but let's
		// be extra careful: Scanner is for safe, simple jobs.
		for loop := 0;; {
			n, err := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if err != nil {
				s.setErr(err)
				break
			}
			if n > 0 {
				s.empties = 0
				break
			}
			loop++
			if loop > 10 {
				s.setErr(io.ErrNoProgress)
				break
			}
		}
	}
}

// advance consumes n bytes of the buffer. It reports whether the advance was legal.
func (s *Scanner) advance(n int) bool {
	if n < 0 {
		s.setErr(ErrNegativeAdvance)
		return false
	}
	if n > s.end - s.start {
		s.setErr(ErrAdvanceTooFar)
		return false
	}
	s.start += n
	return true
}

// setErr records the first error encountered.
func (s *Scanner) setErr(err error) {
	if s.err == nil || s.err == io.EOF {
		s.err = err
	}
}

// Buffer sets the initial buffer to use when scanning and the maximum
// size of buffer that may be allocated during scanning. The maximum
// token size is the larger of max and cap(buf). If max <= cap(buf),
// Scan will use this buffer only and do no allocation.
//
// By default, Scan uses an internal buffer and sets the
// maximum token size to MaxScanTokenSize.
//
// Buffer panics if it is called after scanning has started.
func (s *Scanner) Buffer(buf []byte, max int) {
	if s.scanCalled {
		panic("Buffer called after Scan")
	}
	s.buf = buf[0:cap(buf)]
	s.maxTokenSize = max
}

// Split sets the split function for the Scanner.
// The default split function is ScanLines.
//
// Split panics if it is called after scanning has started.
func (s *Scanner) Split(split SplitFunc) {
	if s.scanCalled {
		panic("Split called after Scan")
	}
	s.split = split
}

// Split functions

// ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	return 1, data[0:1], nil
}

var errorRune = []byte(string(utf8.RuneError))

// ScanRunes is a split function for a Scanner that returns each
// UTF-8-encoded rune as a token. The sequence of runes returned is
// equivalent to that from a range loop over the input as a string, which
// means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd".
// Because of the Scan interface, this makes it impossible for the client to
// distinguish correctly encoded replacement runes from encoding errors.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}

	// Fast path 1: ASCII.
	if data[0] < utf8.RuneSelf {
		return 1, data[0:1], nil
	}

	// Fast path 2: Correct UTF-8 decode without error.
	_, width := utf8.DecodeRune(data)
	if width > 1 {
		// It's a valid encoding. Width cannot be one for a correctly encoded
		// non-ASCII rune.
		return width, data[0:width], nil
	}

	// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.
	// Is the error because there wasn't a full rune to be decoded?
	// FullRune distinguishes correctly between erroneous and incomplete encodings.
	if !atEOF && !utf8.FullRune(data) {
		// Incomplete; get more bytes.
		return 0, nil, nil
	}

	// We have a real UTF-8 encoding error. Return a properly encoded error rune
	// but advance only one byte. This matches the behavior of a range loop over
	// an incorrectly encoded string.
	return 1, errorRune, nil
}

// dropCR drops a terminal \r from the data.
func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data) - 1] == '\r' {
		return data[0 : len(data) - 1]
	}
	return data
}

// ScanLines is a split function for a Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one optional carriage return followed
// by one mandatory newline. In regular expression notation, it is `\r?\n`.
// The last non-empty line of input will be returned even if it has no
// newline.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		// We have a full newline-terminated line.
		return i + 1, dropCR(data[0:i]), nil
	}
	// If we're at EOF, we have a final, non-terminated line. Return it.
	if atEOF {
		return len(data), dropCR(data), nil
	}
	// Request more data.
	return 0, nil, nil
}

// isSpace reports whether the character is a Unicode white space character.
// We avoid dependency on the unicode package, but check validity of the implementation
// in the tests.
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

// ScanWords is a split function for a Scanner that returns each
// space-separated word of text, with surrounding spaces deleted. It will
// never return an empty string. The definition of space is set by
// unicode.IsSpace.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return start, nil, nil
}

package main

import (
	"strings"
	"fmt"
	"strconv"
	"errors"
	"io"
	"unicode/utf8"
	"bytes"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
func main() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("error: ", r)
		}
	}()
	n, a, b := nextInt(), nextInt(), nextInt()
	hp := make([]int, n)
	totalHp := 0
	for i := 0; i < n; i++ {
		hp[i] = nextInt() + 1
		totalHp += hp[i]
	}
	hits, order := 0, make([]int, 0)
	for totalHp > 0 {
		maxDmg := 0
		hit := 0
		for i := 1; i < n - 1; i++ {
			curDmg := min(hp[i - 1], b) + min(hp[i], a) + min(hp[i + 1], b)
			if maxDmg < curDmg {
				maxDmg = curDmg
				hit = i
			}
		}
		hits++
		order = append(order, hit + 1)
		totalHp -= maxDmg
		hp[hit - 1], hp[hit], hp[hit + 1] = hp[hit - 1] - min(hp[hit - 1], b), hp[hit] - min(hp[hit], a), hp[hit + 1] - min(hp[hit + 1], b)
	}
	res := fmt.Sprintf("%v", order)
	res = res[1:len(res)-1]
	printf("%d\n%s\n", hits, res)
}

var lineScanner *Scanner
var wordScanner *Scanner

func init() {
	lineScanner = NewScanner(os.Stdin)
	wordScanner = NewScanner(strings.NewReader(""))
	wordScanner.Split(ScanWords)
}

func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = NewScanner(strings.NewReader(line))
		wordScanner.Split(ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

// Scanner provides a convenient interface for reading data such as
// a file of newline-delimited lines of text. Successive calls to
// the Scan method will step through the 'tokens' of a file, skipping
// the bytes between the tokens. The specification of a token is
// defined by a split function of type SplitFunc; the default split
// function breaks the input into lines with line termination stripped. Split
// functions are defined in this package for scanning a file into
// lines, bytes, UTF-8-encoded runes, and space-delimited words. The
// client may instead provide a custom split function.
//
// Scanning stops unrecoverably at EOF, the first I/O error, or a token too
// large to fit in the buffer. When a scan stops, the reader may have
// advanced arbitrarily far past the last token. Programs that need more
// control over error handling or large tokens, or must run sequential scans
// on a reader, should use bufio.Reader instead.
//
type Scanner struct {
	r            io.Reader // The reader provided by the client.
	split        SplitFunc // The function to split the tokens.
	maxTokenSize int       // Maximum size of a token; modified by tests.
	token        []byte    // Last token returned by split.
	buf          []byte    // Buffer used as argument to split.
	start        int       // First non-processed byte in buf.
	end          int       // End of data in buf.
	err          error     // Sticky error.
	empties      int       // Count of successive empty tokens.
	scanCalled   bool      // Scan has been called; buffer is in use.
	done         bool      // Scan has finished.
}

// SplitFunc is the signature of the split function used to tokenize the
// input. The arguments are an initial substring of the remaining unprocessed
// data and a flag, atEOF, that reports whether the Reader has no more data
// to give. The return values are the number of bytes to advance the input
// and the next token to return to the user, plus an error, if any. If the
// data does not yet hold a complete token, for instance if it has no newline
// while scanning lines, SplitFunc can return (0, nil, nil) to signal the
// Scanner to read more data into the slice and try again with a longer slice
// starting at the same point in the input.
//
// If the returned error is non-nil, scanning stops and the error
// is returned to the client.
//
// The function is never called with an empty data slice unless atEOF
// is true. If atEOF is true, however, data may be non-empty and,
// as always, holds unprocessed text.
type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)

// Errors returned by Scanner.
var (
	ErrTooLong = errors.New("bufio.Scanner: token too long")
	ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count")
	ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input")
)

const (
// MaxScanTokenSize is the maximum size used to buffer a token
// unless the user provides an explicit buffer with Scan.Buffer.
// The actual maximum token size may be smaller as the buffer
// may need to include, for instance, a newline.
	MaxScanTokenSize = 2 * 1024 * 2014

	startBufSize = 4096 // Size of initial allocation for buffer.
)

// NewScanner returns a new Scanner to read from r.
// The split function defaults to ScanLines.
func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        ScanLines,
		maxTokenSize: MaxScanTokenSize,
	}
}

// Err returns the first non-EOF error that was encountered by the Scanner.
func (s *Scanner) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}

// Bytes returns the most recent token generated by a call to Scan.
// The underlying array may point to data that will be overwritten
// by a subsequent call to Scan. It does no allocation.
func (s *Scanner) Bytes() []byte {
	return s.token
}

// Text returns the most recent token generated by a call to Scan
// as a newly allocated string holding its bytes.
func (s *Scanner) Text() string {
	return string(s.token)
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the Scanner to the next token, which will then be
// available through the Bytes or Text method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
// Scan panics if the split function returns 100 empty tokens without
// advancing the input. This is a common error mode for scanners.
func (s *Scanner) Scan() bool {
	if s.done {
		return false
	}
	s.scanCalled = true
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		// If we've run out of data but have an error, give the split function
		// a chance to recover any remaining, possibly empty token.
		if s.end > s.start || s.err != nil {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				if err == ErrFinalToken {
					s.token = token
					s.done = true
					return true
				}
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				if s.err == nil || advance > 0 {
					s.empties = 0
				} else {
					// Returning tokens not advancing input at EOF.
					s.empties++
					if s.empties > 100 {
						panic("bufio.Scan: 100 empty tokens without progressing")
					}
				}
				return true
			}
		}
		// We cannot generate a token with what we are holding.
		// If we've already hit EOF or an I/O error, we are done.
		if s.err != nil {
			// Shut it down.
			s.start = 0
			s.end = 0
			return false
		}
		// Must read more data.
		// First, shift data to beginning of buffer if there's lots of empty space
		// or space is needed.
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		// Is the buffer full? If so, resize.
		if s.end == len(s.buf) {
			// Guarantee no overflow in the multiplication below.
			const maxInt = int(^uint(0) >> 1)
			if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			if newSize == 0 {
				newSize = startBufSize
			}
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		// Finally we can read some input. Make sure we don't get stuck with
		// a misbehaving Reader. Officially we don't need to do this, but let's
		// be extra careful: Scanner is for safe, simple jobs.
		for loop := 0;; {
			n, err := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if err != nil {
				s.setErr(err)
				break
			}
			if n > 0 {
				s.empties = 0
				break
			}
			loop++
			if loop > 10 {
				s.setErr(io.ErrNoProgress)
				break
			}
		}
	}
}

// advance consumes n bytes of the buffer. It reports whether the advance was legal.
func (s *Scanner) advance(n int) bool {
	if n < 0 {
		s.setErr(ErrNegativeAdvance)
		return false
	}
	if n > s.end - s.start {
		s.setErr(ErrAdvanceTooFar)
		return false
	}
	s.start += n
	return true
}

// setErr records the first error encountered.
func (s *Scanner) setErr(err error) {
	if s.err == nil || s.err == io.EOF {
		s.err = err
	}
}

// Buffer sets the initial buffer to use when scanning and the maximum
// size of buffer that may be allocated during scanning. The maximum
// token size is the larger of max and cap(buf). If max <= cap(buf),
// Scan will use this buffer only and do no allocation.
//
// By default, Scan uses an internal buffer and sets the
// maximum token size to MaxScanTokenSize.
//
// Buffer panics if it is called after scanning has started.
func (s *Scanner) Buffer(buf []byte, max int) {
	if s.scanCalled {
		panic("Buffer called after Scan")
	}
	s.buf = buf[0:cap(buf)]
	s.maxTokenSize = max
}

// Split sets the split function for the Scanner.
// The default split function is ScanLines.
//
// Split panics if it is called after scanning has started.
func (s *Scanner) Split(split SplitFunc) {
	if s.scanCalled {
		panic("Split called after Scan")
	}
	s.split = split
}

// Split functions

// ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	return 1, data[0:1], nil
}

var errorRune = []byte(string(utf8.RuneError))

// ScanRunes is a split function for a Scanner that returns each
// UTF-8-encoded rune as a token. The sequence of runes returned is
// equivalent to that from a range loop over the input as a string, which
// means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd".
// Because of the Scan interface, this makes it impossible for the client to
// distinguish correctly encoded replacement runes from encoding errors.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}

	// Fast path 1: ASCII.
	if data[0] < utf8.RuneSelf {
		return 1, data[0:1], nil
	}

	// Fast path 2: Correct UTF-8 decode without error.
	_, width := utf8.DecodeRune(data)
	if width > 1 {
		// It's a valid encoding. Width cannot be one for a correctly encoded
		// non-ASCII rune.
		return width, data[0:width], nil
	}

	// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.
	// Is the error because there wasn't a full rune to be decoded?
	// FullRune distinguishes correctly between erroneous and incomplete encodings.
	if !atEOF && !utf8.FullRune(data) {
		// Incomplete; get more bytes.
		return 0, nil, nil
	}

	// We have a real UTF-8 encoding error. Return a properly encoded error rune
	// but advance only one byte. This matches the behavior of a range loop over
	// an incorrectly encoded string.
	return 1, errorRune, nil
}

// dropCR drops a terminal \r from the data.
func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data) - 1] == '\r' {
		return data[0 : len(data) - 1]
	}
	return data
}

// ScanLines is a split function for a Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one optional carriage return followed
// by one mandatory newline. In regular expression notation, it is `\r?\n`.
// The last non-empty line of input will be returned even if it has no
// newline.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		// We have a full newline-terminated line.
		return i + 1, dropCR(data[0:i]), nil
	}
	// If we're at EOF, we have a final, non-terminated line. Return it.
	if atEOF {
		return len(data), dropCR(data), nil
	}
	// Request more data.
	return 0, nil, nil
}

// isSpace reports whether the character is a Unicode white space character.
// We avoid dependency on the unicode package, but check validity of the implementation
// in the tests.
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

// ScanWords is a split function for a Scanner that returns each
// space-separated word of text, with surrounding spaces deleted. It will
// never return an empty string. The definition of space is set by
// unicode.IsSpace.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return start, nil, nil
}


For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le 100$$$) — the elements of the array $$$d$$$. It can be shown that there always exists at least one suitable array $$$a$$$ under these constraints.

For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.

NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func trim(s string) string {
	return s[:len(s)-2]
}

func checkNumberPowerOfTwo(n int) int {
	return n & (n - 1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func sliceStr2Int(arr []string) []int {
	var arrInt []int
	for _, i := range arr {
		num, _ := strconv.Atoi(i)
		arrInt = append(arrInt, num)
	}

	return arrInt
}

func sliceIntFromConsole() []int {
	arrLine, _ := reader.ReadString('\n')
	return sliceStr2Int(strings.Split(trim(arrLine), " "))
}

func numberFromConsole() int {
	numberLine, _ := reader.ReadString('\n')
	number, _ := strconv.Atoi(trim(numberLine))
	return number
}

var reader = bufio.NewReader(os.Stdin)

func main() {
	testLine, _ := reader.ReadString('\n')
	test, _ := strconv.Atoi(trim(testLine))

	for t := 0; t < test; t++ {
		n := numberFromConsole()
		d := sliceIntFromConsole()

		a := make([]int, n)
		a[0] = d[0]

		impossible := false
		for i := 1; i < n; i++ {
			difference := a[i-1] - d[i]
			if difference >= 0 && d[i] != 0 {
				impossible = true
				break
			}
			a[i] = a[i-1] + d[i]
		}

		if impossible {
			fmt.Println(-1)
		} else {
			for _, i := range a {
				fmt.Print(i, " ")
			}
			fmt.Println()
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([]int, n)
		bb[0] = aa[0]
		f := true
		for i := 1; i < n; i++ {
			bb[i] = bb[i-1] + aa[i]
			if bb[i-1]-aa[i] >= 0 && bb[i-1]-aa[i] != bb[i] {
				f = false
				break
			}
		}

		if !f {
			fmt.Fprintln(out, -1)
		} else {
			for _, v := range bb {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	txt, _ := reader.ReadString('\n')
	q, _ := strconv.Atoi(strings.TrimSpace(txt))
	for ; q > 0; q-- {
		txt, _ = reader.ReadString('\n')
		n, _ := strconv.Atoi(strings.TrimSpace(txt))
		txt, _ = reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(txt), " ")
		a := make([]int, n, n)
		for i := 0; i < n; i++ {
			cur, _ := strconv.Atoi(arr[i])
			if i == 0 {
				a[i] = cur
			} else {
				one, two := a[i-1]+cur, a[i-1]-cur
				if one >= 0 && two < 0 || one == two {
					a[i] = one
				} else {
					a[0] = -1
					break
				}
			}
		}
		if a[0] == -1 {
			fmt.Println(-1)
		} else {
			for _, d := range a {
				fmt.Printf("%d ", d)
			}
			fmt.Println()
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, d []int) string {
	a := make([]int, n)
	a[0] = d[0]
	for i := 1; i < n; i++ {
		if d[i] > 0 && a[i-1] >= d[i] {
			return "-1"
		}
		a[i] = a[i-1] + d[i]
	}
	return strings.Trim(fmt.Sprint(a), "[]")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		d := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &d[i])
		}
		fmt.Println(solve(n, d))
	}
}

package main

import (
	"fmt"
	"os"
	"bufio"
)

func solve(d []int) ([]int, bool) {
	ret := make([]int, len(d))
	ret[0] = d[0]

	for i := 1; i < len(d); i++ {
		if ret[i - 1] - d[i] >= 0 && d[i] != 0 {
			return nil, false
		}

		ret[i] = ret[i - 1] + d[i]
	}

	return ret, true
}

func main() {
	in := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)

		d := make([]int, n)
		for i := range d {
			fmt.Fscan(in, &d[i])
		}

		a, ok := solve(d)

		if ok {
			for i := range a {
				fmt.Printf("%d ", a[i])
			}
			fmt.Println()

		} else {
			fmt.Println(-1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1739B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1739B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1739B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1739B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1739B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1739B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1739B
Date: 9/30/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1739/B
Problem: CF1739B
**/
func (in *CF1739B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}
		sol := make([]int, n)
		sol[0] = arr[0]
		ans := true
		for i := 1; i < n; i++ {
			a := sol[i-1] + arr[i]
			b := sol[i-1] - arr[i]
			if a >= 0 && b >= 0 && a != b {
				ans = false
				break
			} else {
				if a >= 0 {
					sol[i] = a
				} else {
					sol[i] = b
				}
			}
		}

		if ans {
			for i := 0; i < n; i++ {
				fmt.Print(sol[i], " ")
			}
			fmt.Println()
		} else {
			fmt.Println(-1)
		}
	}
}

func NewCF1739B(r *bufio.Reader) *CF1739B {
	return &CF1739B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1739B(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func do(in []int) {
	out := []int{}
	for i := range in {
		if i == 0 {
			out = append(out, in[i])
			continue
		}

		if in[i] != 0 && (out[i-1]+in[i]) >= 0 && (out[i-1]-in[i]) >= 0 {
			fmt.Println("-1")
			return
		}

		out = append(out, out[i-1]+in[i])
	}

	for i := range out {
		if i != 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", out[i])
	}
	fmt.Println()
}

func main() {

	var line string
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line = scanner.Text()
	fields := strings.Fields(line)
	cases, _ := strconv.Atoi(fields[0])

	for i := 0; i < cases; i++ {
		scanner.Scan()
		scanner.Scan()
		line = scanner.Text()
		out := []int{}
		for _, n := range strings.Fields(line) {
			n1, _ := strconv.Atoi(n)
			out = append(out, n1)
		}

		do(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func trim(s string) string {
	return s[:len(s)-2]
}

func checkNumberPowerOfTwo(n int) int {
	return n & (n - 1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func sliceStr2Int(arr []string) []int {
	var arrInt []int
	for _, i := range arr {
		num, _ := strconv.Atoi(i)
		arrInt = append(arrInt, num)
	}

	return arrInt
}

func sliceIntFromConsole() []int {
	arrLine, _ := reader.ReadString('\n')
	return sliceStr2Int(strings.Split(trim(arrLine), " "))
}

func numberFromConsole() int {
	numberLine, _ := reader.ReadString('\n')
	number, _ := strconv.Atoi(trim(numberLine))
	return number
}

var reader = bufio.NewReader(os.Stdin)

func main() {
	testLine, _ := reader.ReadString('\n')
	test, _ := strconv.Atoi(trim(testLine))

	for t := 0; t < test; t++ {
		n := numberFromConsole()
		d := sliceIntFromConsole()

		a := make([]int, n)
		a[0] = d[0]

		impossible := false
		for i := 1; i < n; i++ {
			difference := a[i-1] - d[i]
			if (difference > 0 && d[i] != 0) || (a[i-1] == d[i]) {
				impossible = true
				break
			}
			a[i] = a[i-1] + d[i]
		}

		if impossible {
			fmt.Println(-1)
		} else {
			for _, i := range a {
				fmt.Print(i, " ")
			}
			fmt.Println()
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func trim(s string) string {
	return s[:len(s)-2]
}

func checkNumberPowerOfTwo(n int) int {
	return n & (n - 1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func sliceStr2Int(arr []string) []int {
	var arrInt []int
	for _, i := range arr {
		num, _ := strconv.Atoi(i)
		arrInt = append(arrInt, num)
	}

	return arrInt
}

func sliceIntFromConsole() []int {
	arrLine, _ := reader.ReadString('\n')
	return sliceStr2Int(strings.Split(trim(arrLine), " "))
}

func numberFromConsole() int {
	numberLine, _ := reader.ReadString('\n')
	number, _ := strconv.Atoi(trim(numberLine))
	return number
}

var reader = bufio.NewReader(os.Stdin)

func main() {
	testLine, _ := reader.ReadString('\n')
	test, _ := strconv.Atoi(trim(testLine))

	for t := 0; t < test; t++ {
		n := numberFromConsole()
		d := sliceIntFromConsole()

		a := make([]int, n)
		a[0] = d[0]

		impossible := false
		for i := 1; i < n; i++ {
			difference := a[i-1] - d[i]
			if difference > 0 && d[i] != 0 {
				impossible = true
				break
			}
			a[i] = a[i-1] + d[i]
		}

		if impossible {
			fmt.Println(-1)
		} else {
			for _, i := range a {
				fmt.Print(i, " ")
			}
			fmt.Println()
		}
	}
}


One day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a letter directly from the city of the sender to the city of the receiver, that's why the letter is sent via some intermediate cities. Post officers never send a letter in such a way that the route of this letter contains some city more than once. Bob is sure that the post officers stamp the letters accurately.There are n stamps on the envelope of Bob's letter. He understands that the possible routes of this letter are only two. But the stamps are numerous, and Bob can't determine himself none of these routes. That's why he asks you to help him. Find one of the possible routes of the letter.

The first line contains integer n (1 ≤ n ≤ 105) — amount of mail stamps on the envelope. Then there follow n lines with two integers each — description of the stamps. Each stamp is described with indexes of the cities between which a letter is sent. The indexes of cities are integers from 1 to 109. Indexes of all the cities are different. Every time the letter is sent from one city to another, exactly one stamp is put on the envelope. It is guaranteed that the given stamps correspond to some valid route from some city to some other city.

Output n + 1 numbers — indexes of cities in one of the two possible routes of the letter.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

var m map[int][]int
var ans strings.Builder
var vis map[int]bool

func dfs(u int) {
	vis[u] = true
	ans.WriteString(fmt.Sprintf("%v ", u))

	for i := 0; i < len(m[u]); i++ {
		v := m[u][i]
		if !vis[v] {
			dfs(v)
		}
	}
}

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	c := make(map[int]int)
	m = make(map[int][]int)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d %d\n", &a, &b)
		m[a] = append(m[a], b)
		m[b] = append(m[b], a)
		c[a]++
		c[b]++
	}

	for k, v := range c {
		if v == 1 {
			a = k
			break
		}
	}
	vis = make(map[int]bool)
	dfs(a)
	fmt.Fprintf(w, "%v\n", ans.String())
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Graph struct {
	Edges   map[int][]int
	Visited map[int]bool
	Order   []int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	g.Order = append(g.Order, u)
	for _, v := range g.Edges[u] {
		if !g.Visited[v] {
			explore(g, v)
		}
	}
}

func main() {
	var reader *bufio.Reader = bufio.NewReader(os.Stdin)
	var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n, u, v int
	fmt.Fscanf(reader, "%d\n", &n)
	g := Graph{Order: make([]int, 0), Visited: make(map[int]bool), Edges: make(map[int][]int)}
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[v] = append(g.Edges[v], u)
	}
	for v, e := range g.Edges {
		if _, ok := g.Visited[v]; !ok && len(e) == 1 {
			explore(&g, v)
		}
	}
	for idx, val := range g.Order {
		if idx == len(g.Order)-1 {
			fmt.Fprintf(writer, "%d\n", val)
		} else {
			fmt.Fprintf(writer, "%d ", val)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	m, c := make(map[int]int), make(map[int]int)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d %d\n", &a, &b)

		_, ok := m[a]
		if ok {
			m[b] = a
			c[b]++
		} else {
			m[a] = b
			c[a]++
		}
	}

	a, b = 0, 0
	for k, v := range c {
		if v == 1 {
			if a == 0 {
				a = k
			} else {
				b = k
				break
			}
		}
	}

	i := 1
	ans := strings.Builder{}
	ans.WriteString(fmt.Sprintf("%d", a))
	for v, ok := m[a]; ok; v, ok = m[v] {
		i += 1
		ans.WriteString(fmt.Sprintf(" %d", v))
	}
	if i != n+1 {
		ans = strings.Builder{}
		ans.WriteString(fmt.Sprintf("%d", b))
		for v, ok := m[b]; ok; v, ok = m[v] {
			ans.WriteString(fmt.Sprintf(" %d", v))
		}

	}
	fmt.Fprintf(w, "%v\n", ans.String())
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	m := make(map[int]int)
	ml, mr := make(map[int]bool), make(map[int]bool)
	c := make(map[int]int)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d %d\n", &a, &b)

		if ml[a] || mr[b] {
			m[b] = a
			ml[b] = true
			mr[a] = true
		} else {
			m[a] = b
			ml[a] = true
			mr[b] = true
		}
		c[a]++
		c[b]++
	}

	a, b = 0, 0
	for k, v := range c {
		if v == 1 {
			if a == 0 {
				a = k
			} else {
				b = k
				break
			}
		}
	}

	i := 1
	ans := strings.Builder{}
	ans.WriteString(fmt.Sprintf("%d", a))
	for v, ok := m[a]; ok; v, ok = m[v] {
		i += 1
		ans.WriteString(fmt.Sprintf(" %d", v))
	}
	if i != n+1 {
		ans = strings.Builder{}
		ans.WriteString(fmt.Sprintf("%d", b))
		for v, ok := m[b]; ok; v, ok = m[v] {
			ans.WriteString(fmt.Sprintf(" %d", v))
		}

	}
	fmt.Fprintf(w, "%v\n", ans.String())
}

package main

import (
	"os"
	"bufio"
	"fmt"
	"strings"
)

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	m, c := make(map[int]int), make(map[int]int)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d %d\n", &a, &b)

		_, ok := m[a]
		if ok {
			m[b] = a
			c[b]++
		} else {
			m[a] = b
			c[a]++
		}
	}

	a, b = 0, 0
	for k, v := range c {
		if v == 1 {
			if a == 0 {
				a = k
			} else {
				b = k
				break
			}
		}
	}

	i := 1
	ans := strings.Builder{}
	ans.WriteString(fmt.Sprintf("%d", a))
	for v, ok := m[a]; ok; v, ok = m[v]{
		i += 1
		ans.WriteString(fmt.Sprintf(" %d", v))
	}
	if i != n+1 {
		ans = strings.Builder{}
		ans.WriteString(fmt.Sprintf("%d", b))
		for v, ok := m[b]; ok; v, ok = m[v]{
			ans.WriteString(fmt.Sprintf(" %d", v))
		}

	}
	fmt.Fprintf(w, "%v", ans.String())
}

package main

import "fmt"

type Graph struct {
	Edges   map[int][]int
	Visited map[int]bool
	Order   []int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	g.Order = append(g.Order, u)
	for _, v := range g.Edges[u] {
		if !g.Visited[v] {
			explore(g, v)
		}
	}
}

func main() {
	var n, u, v int
	fmt.Scanf("%d", &n)
	g := Graph{Order: make([]int, 0), Visited: make(map[int]bool), Edges: make(map[int][]int)}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[v] = append(g.Edges[v], u)
	}
	for v, e := range g.Edges {
		if _, ok := g.Visited[v]; !ok && len(e) == 1 {
			explore(&g, v)
		}
	}
	fmt.Println(g.Order)
	for idx, val := range g.Order {
		if idx == len(g.Order)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
}

package main

import "fmt"

type Graph struct {
	Edges   map[int][]int
	Visited map[int]bool
	Order   []int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	g.Order = append(g.Order, u)
	for _, v := range g.Edges[u] {
		if !g.Visited[v] {
			explore(g, v)
		}
	}
}

func main() {
	var n, u, v int
	fmt.Scanf("%d", &n)
	g := Graph{Order: make([]int, 0), Visited: make(map[int]bool), Edges: make(map[int][]int)}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[v] = append(g.Edges[v], u)
	}
	for v, e := range g.Edges {
		if _, ok := g.Visited[v]; !ok && len(e) == 1 {
			explore(&g, v)
		}
	}
	for idx, val := range g.Order {
		if idx == (len(g.Order)-1) {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
}

package main

import "fmt"

type Graph struct {
	Edges   map[int][]int
	Visited map[int]bool
	Order   []int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	g.Order = append(g.Order, u)
	for _, v := range g.Edges[u] {
		if !g.Visited[v] {
			explore(g, v)
		}
	}
}

func main() {
	var n, u, v int
	fmt.Scanf("%d", &n)
	g := Graph{Order: make([]int, 0), Visited: make(map[int]bool), Edges: make(map[int][]int)}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d%d", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[v] = append(g.Edges[v], u)
	}
	for v, e := range g.Edges {
		if _, ok := g.Visited[v]; !ok && len(e) == 1 {
			explore(&g, v)
		}
	}
	for idx, val := range g.Order {
		if idx == len(g.Order)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
}

package main

import "fmt"

type Graph struct {
	Edges   map[int][]int
	Visited map[int]bool
	Order   []int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	g.Order = append(g.Order, u)
	for _, v := range g.Edges[u] {
		if !g.Visited[v] {
			explore(g, v)
		}
	}
}

func main() {
	var n, u, v int
	fmt.Scanf("%d", &n)
	g := Graph{Order: make([]int, 0), Visited: make(map[int]bool), Edges: make(map[int][]int)}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[v] = append(g.Edges[v], u)
	}
	for v, e := range g.Edges {
		if _, ok := g.Visited[v]; !ok && (len(e) == 1) {
			explore(&g, v)
		}
	}
	for idx, val := range g.Order {
		if idx == len(g.Order)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
}