← Home
```go
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int64
	fmt.Scan(&a, &b, &c, &d)
	
	var op1, op2, op3 string
	fmt.Scan(&op1, &op2, &op3)
	
	ops := []string{op1, op2, op3}
	nums := []int64{a, b, c, d}
	
	result := int64(math.MaxInt64)
	
	// Try all permutations of 4 numbers
	perm4 := permutations([]int{0, 1, 2, 3})
	
	for _, p := range perm4 {
		// p[0], p[1] are combined with ops[0]
		// result and p[2] are combined with ops[1]
		// result and p[3] are combined with ops[2]
		
		// But we need to consider all ways to pick pairs at each step
		// Step 1: pick 2 from 4, apply ops[0], get 3 numbers
		// Step 2: pick 2 from 3, apply ops[1], get 2 numbers
		// Step 3: pick 2 from 2, apply ops[2], get 1 number
		_ = p
	}
	
	// Let's do it properly with recursion/brute force
	result = solve(nums, ops)
	
	fmt.Println(result)
}

func apply(a, b int64, op string) int64 {
	if op == "+" {
		return a + b
	}
	return a * b
}

func solve(nums []int64, ops []string) int64 {
	if len(nums) == 1 {
		return nums[0]
	}
	
	best := int64(math.MaxInt64)
	
	// Try all pairs
	for i := 0; i < len(nums); i++ {
		for j := i + 1; j < len(nums); j++ {
			// Combine nums[i] and nums[j] with ops[0]
			val := apply(nums[i], nums[j], ops[0])
			
			// Build new list
			newNums := []int64{val}
			for k := 0; k < len(nums); k++ {
				if k != i && k != j {
					newNums = append(newNums, nums[k])
				}
			}
			
			res := solve(newNums, ops[1:])
			if res < best {
				best = res
			}
		}
	}
	
	return best
}

func permutations(arr []int) [][]int {
	if len(arr) == 0 {
		return [][]int{{}}
	}
	result := [][]int{}
	for i, v := range arr {
		rest := make([]int, 0, len(arr)-1)
		rest = append(rest, arr[:i]...)
		rest = append(rest, arr[i+1:]...)
		for _, p := range permutations(rest) {
			perm := append([]int{v}, p...)
			result = append(result, perm)
		}
	}
	return result
}
```