array transform

answer
giving
why
wrong

#1

#include<stdio.h>

int main()
{
int f,i,j,k,l,m,n,p,t,q,r,c,z;
scanf("%d",&t);
for(q=0;q<t;q++)
{ f=1;
z=0;
scanf("%d %d",&n,&k);
int a[n];
for(r=0;r<n;r++)
{
scanf("%d",&a[r]);
if(a[r]==0)
z++;
}
c=1;
for(i=1;i<n;i++)
{
if(a*==a[i-1])
c++;
else
{
k=a[i-1];
l=a*;
break;
}
}
if(c==1)
{
if(a[i+1]==k || a[i+1]==l)
{
if(a[i+1]==k)
m=k;
else
m=l;
}
else
f=0;

				   }
		 else
	       {
	       	for(p=i+1;p<n;p++)
	       	{if(a[p]!=a[i-1])
	       	    {f=0;
	       	    break;
				   }
			   }
		}
			   if(f==1 && z<2)
			   printf("YES

");

			   else
			{  if(z==n-1)
			   printf("YES

");
else
printf("NO
");
}

   }
return 0;   

}


#2

Paste your code in proper blocks with the link of question.