/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int Binary()
{ int i,j,n,k;
int A[n];
printf("size of array:");
scanf("%d",&n);
for(int a=0;a<n;a++)
{ scanf("%d",&A[a]);}
i=0; j=n;
while(i<j)
{ k = (i+j)/2;
if(A[k]==1)
{ if(A[k-1]==0) return k;
else j=k-1;
}
else
{ if (A[k+1]==1) return k+1;
else i = k+1;
}
}
}
int main()
{
//A[8]={0,0,0,0,1,1,1,1};
int index;
index = Binary();
printf("smallest index of 1 is %d", index);
return 0;
}