#include <bits/stdc++.h>
using namespace std;
#define light                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define test  \
    ll t;     \
    cin >> t; \
    while (t--)
#define forl(n) for (ll i = 0; i < n; i++)
#define M5 100005
#define M6 1000005

void approach2(int array[], int n)
{
    int count = 0;
    forl(n)
    {
        if (array[i] == 0)
            ++count;
        else if (count)
        {
            array[i - count] = array[i];
            array[i] = 0;
        }
    }
    forl(n)
    {
        cout << array[i] << " ";
    }
}
void approach1(int array[], int n)
{
    int count = 0;
    forl(n)
    {
        if (array[i] != 0)
        {
            swap(array[i], array[count]);
            ++count;
        }
    }
    forl(n)
    {
        cout << array[i] << " ";
    }
}

int main()
{
    int array[] = {1, 0, 2, 0, 0, 3, 0, 5, 0, 1};
    approach1(array, 10);
}