traverses the array p

for (i=1;i<=n;i++)

printf("\n%d\n",p[i]);

printf("\n");