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.

sabka_din_aayega | 317 |

maggiiiii | 248 |

thanuvinu94 | 211 |

Savage_19 | 206 |

Anugrah_kumar | 172 |

Bishnu Dev Panda | 803 |

sabka_din_aayega | 628 |

Anugrah_kumar | 562 |

okayboss | 561 |

maggiiiii | 531 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.