C++, Insert Sort not working : I am learning sorting algorithms. I googled the insert sort code and when I tried it on my own it's not working out. Can someone please find the error in it? Thank you.

    #include<iostream>
    using namespace std;
    int main()
    {
    	int i,size, a[40], key;
    	cout<<"Enter size: ";
    	cin>>size;
    	for(int o=0; o<size; o++)
    	{
    		cin>>a[o];
    	}
    	//insertion sort
    	for(int j=1; j<=size-1; j++)
    	{
    		key=a[j];
    		i=j-1;
    		
    		while((key<a[i])&&(i>=0));
    		{
    		  a[i+1]=a[i];
    		  i=i-1;
    		}
    		a[i+1]=key;
    	}
    	cout<<"\nSorted list is as follows\n";
    	for(int o=0; o<size; o++)
    	{
    		cout<<endl<<a[o];
    	}

}