All elements distinct?

No, each element does not need to be distinct. Since you are returning indices, which do need to be distinct (in1 < in2), the two could have the same content and have different indices to be a valid sum.
{2,2,3,5} sum = 4 would return 0,1, since the same index cannot be chosen twice, and must maintain an internal order, leaving only one solution.