how to tackle repeated permutation in number of solution?

I am working on classic DP problem: Counting the number of solutions or say a problem like this.
I learned and worked out a DP approach this:

ll *dp = new ll[MAX+1];
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int i = 1; i <= MAX; ++i){
        for(int j = 0; j < n && a[j] <= i; ++j){
            dp[i]+=(dp[i-a[j]]);
        }
    }   

But problem is that it includes repeated permutations as well
for example for input

a[] = {1, 2, 3}
value = 3
It computes for {1,1,1}, {1,2}, {2,1},{3}

How can I avoid these repeated permutations like {1,2} and {2,1}.

Thank you

I am not sure about this
but I dont think this statement in your code is
correct, could you please explain your logic for it?
dp[i]+=(dp[i-a[j]]);

See, let’s suppose coin system is 1,2,3

let’s say we want to find the sum of 4.

dp[4] = 0 (initially)

goes to coin 1

dp[4] += dp[3] (number of ways 3 can be written and then add 1)

dp[4] += dp[2] (number of ways 2 can be written and then add 2)

dp[4] += dp[1] (number of ways 1 can be written and then add 3)