Help me in solving AOCV205 problem

My issue

how we are updating the new array i am not getting

My code

// Update the '_' in the code below to solve the problem

#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int t;
    cin >> t;
	
	while(t--)
	{
	    int N;
	    cin >> N;
	    int A[N];
	    for(int i=0; i < N; i++)
	    {
	        cin >> A[i];
	    }
	    int minElement = A[0];
        int minElementIndex = 0;
        int i;
        for(i=1; i<N; i++)
        {
            if (A[i] < minElement)
            {
                //If we find an element smaller than the previous smallest, we update
                minElement = A[i];
                minElementIndex = i;
            }
            
        }
        //We are starting the operation from index of the smallest element
        i = minElementIndex;
        while(i > 0)
        {
            int temp = A[i];
            A[i] = A[i-1];
            A[i-1] = temp;
            i--;
        }
        for(int i=0; i < N; i++)
        {
            cout<< A[i] << " ";
        }
        cout << endl;
	}
}

Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

@kartikapaul23
We are swapping it back
like ex 5 4 3 1 2
first u will find the smallest element which is at index 3(when consider 0 based indexing).
now u go at 3 and swap back one step
like this :-
5 4 1 3 2
then 5 1 4 3 2
then 1 5 4 3 2
we swap back until we reach the index 0;