Timer is Running

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.

abnandi04 | 801 |

KshamaGupta | 560 |

mummy | 322 |

NikhilGupta0301 | 260 |

jagseersinghbe18cse | 251 |

abnandi04 | 776 |

KshamaGupta | 444 |

mummy | 235 |

srivastavad270 | 223 |

bhavyapratap56 | 206 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4748 |

Login to report an issue on this page.