Run Error in final Exam

ques: https://hack.codingblocks.com/dcb/p/1558
code: https://ide.codingblocks.com/s/63431

I have use a map to store the distinct elements with their counts and found the answer using Bottom Up DP.
It says run error on submitting.
Also is the logic correct?

Wrong test case:
3
1 2 3
your output :
2
correct output :
6
Hit like if u get it :slight_smile: