Under construction

Still being built. Things may change

My Number

Time limit1sMemory limit256 MB

Summary
Build an array B of at most 12 integers, then write an expression over B with +, -, *, and brackets for each target A_i.
Level

Medium7 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Taaaamara is a big fan of the Serbian quiz Slagalica. Her favorite game in the quiz is My Number. In this game you get a set of integers SS and one target number TT. You can use each element of SS at most once and some mathematical operations to build a valid expression equal to TT. For example, if S={2,5,2,15,10}S = \{2, 5, 2, 15, 10\} and T=38T = 38, one valid expression is 2×(15+5)−22 \times (15 + 5) - 2.

Today, Taaaamara is playing a modification of this game:

  • She has an array AA with nn integers, all of them target numbers.
  • She needs to find an array BB with kk elements (elements of BB do not have to be different). All elements of BB must be integers in the range [1,108][1, 10^8].
  • She wants to build one valid expression for each target number AiA_i using only elements from BB. If some element appears xx times in BB, each expression can use that element at most xx times.
  • She can use the binary operators + (addition), - (subtraction), and * (multiplication). Division is not allowed. She can also use brackets.
  • The length kk of array BB is not fixed, but it must not be bigger than 1212 (k≤12k \leq 12).

Can you help her?

Input

The first line contains an integer nn (1≤n≤1241 \leq n \leq 124). The second line contains nn integers, the array AA (1≤Ai≤1081 \leq A_i \leq 10^8).

Output

In the first line, print the integer k≤12k \leq 12, the length of array BB. In the second line, print the kk integers of BB. Each of the next nn lines contains one valid expression, where the ii-th line has a value equal to AiA_i. Expressions must follow these rules:

  • Each expression has at most 1000 characters.
  • Addition uses + (ASCII 43).
  • Subtraction uses - (ASCII 45).
  • Multiplication uses * (ASCII 42).
  • Brackets use ( (ASCII 40) and ) (ASCII 41).
  • + and - cannot be used as unary operators. For example, -5 + 3 and 5 - -3 are not valid.
  • Besides these characters, you can only use numbers from BB and spaces (ASCII 32).

Special formatting of the output is not needed.

Examples1

  1. Example 1

    Input
    6
    30 13 15 5 3 21
    
    Expected output
    3
    2 5 3
    2*5*3
    5*3- 2
    5 *3
       (5)
    5 -2
    3* (5+2 )