Array-target sum triplets

what is wrong with this code,it does not print anything:
#include
#include
using namespace std;
int main(){
int n,sum;
cin>>n;
int a[n];
for(int i=0 ; i<n ; i++)
{
cin>>a[i];
}
cin>>sum;
sort(a,a+n);
for(int i=0 ; i<n-2 ; i++)
{
int l,r;
l = i+1;
r=n-1;
while(l<r)
{
if(a[i] + a[l] + a[r] == sum )
{
cout<<a[i]<<", “<<a[l]<<” and "<<a[r]<<endl;
}
else if(a[i] + a[l] + a[r] > sum)
{
r–;
}
else{
l++;
}
}
}
return 0;
}