the integer n is not at the right end, so shift it
p[l[n]] = p[l[n]+1];
p[l[n]+1] = n;
l[n] = l[n]+1;