[1,2,1,2,1]

in the case of these numbers, it seems the output should be 13.

for 3times 1 = 3*3 = 9
for 2times 2 = 2*2 = 4

9 + 4 = 13.

but it says expected output is 11.

can someone please explain it?

```
int nbox = boxesSize;
char a; int i = 0, rn = 0, ans = 0, j;
while(i < nbox )
{
if((*(boxes+i)) != -1)
{a = (*(boxes+i));
(*(boxes+i)) = -1;
rn = 1;
for(j = 0; j< nbox;j++ )
{
if(a == (*(boxes+j)) && (*(boxes+j)) != -1 )
{rn++; (*(boxes+j)) = -1;}
}
ans = ans +( rn * rn);
rn = 0;}
i++;
}
return ans;
}
```