import java.util.Scanner object Problem004 { def proc(n: Int, weight: Seq[Int]): String = { if (weight.sum % 2 != 0) { return "impossible" } val target = weight.sum / 2 val dp = Array.fill(target + 1)(false) dp(0) = true for (w <- weight) { for (d <- target - w to 0 by -1 if dp(d)) { dp(d + w) = true } } if (dp(target)) "possible" else "impossible" } def main(args: Array[String]): Unit = { val sc = new Scanner(System.in) val n = sc.nextInt() val weight = Seq.fill(n)(sc.nextInt()) val result: String = proc(n, weight) println(result) } }