Given an array of digits (values are from **0 to 9**). Find the **minimum** possible sum of two numbers formed from digits of the array. All digits of given array must be used to form the two numbers.

**Input:**

The first line of input contains a single integer **T** denoting the number of test cases. Then** T** test cases follow. Each test case consist of two lines. The first line of each test case consists of an integer **N**, where **N** is the size of array.

The second line of each test case contains **N** space separated integers denoting array elements.

**Output:**

For each testcase, print the minimum possible sum of two numbers formed from digits of the array.

**Constraints:**

1 ≤ T ≤ 300

1 ≤ N ≤ 10^{7}

0 ≤ A_{i} ≤ 9

**Example:
Input**:

1

5

5 3 0 7 4

82

**Explanation:**

**Testcase 1:** **35 **and **47** gives the smallest sum out of all possible combinations of numbers. Their sum is **82.**

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

jhasaurabh312 | 138 |

Aaaaarohiiii | 136 |

Harsha_kunchala | 128 |

tushki | 124 |

RajaRajput | 117 |

ARUN_PUNDIR | 617 |

manishgupta8497 | 607 |

Abhimanyu_kumar | 559 |

KhyatiSoneji | 501 |

Aman___Jain | 496 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.