**Author** : codechef_ciem | CodeChef CIEM Chapter

**Problem link** : SumDuct | CodeChef

**Problem Statement** :

Chef is attending math classes. On each day, the teacher gives him homework. Yesterday, the teacher gave Chef a sequence of positive integers and asked him to find the maximum product of two different elements of this sequence. This homework was easy for Chef, since he knew that he should select the biggest two numbers.

However, today, the homework is a little bit different. Again, Chef has a sequence of positive integers A1,A2,…,AN but he should find two different elements of this sequence such that the sum of digits (in base 10) of their product is maximum possible.

Chef thought, mistakenly, that he can still select the two largest elements and compute the sum of digits of their product. Show him that he is wrong by finding the correct answer ― the maximum possible sum of digits of a product of two different elements of the sequence A.

**Solution** :

```
t=int(input())
while t>0:
n=int(input())
li=list(map(int,input().split(" ")))
ans=-1
for i in range(0,n):
for j in range(i+1,n):
p=li[i]*li[j]
s=0
while p>0:
s+=(p%10)
p=p//10
if s>ans:
ans=s
print(ans)
t-=1
```