traverses and fills the array
p
and
1
for (i = 1;i<=n;i++)
{
p[i] = n - i + 1;
l[i] = 1;