#include <bits/stdc++.h> using namespace std; int main() { int n; int a[25] , b; while(cin >> n)

{ for( int i = 0 ; i < n ; i ++ )    cin >> a[i];
cin >> b;

int s = 0;
bool yf = false;
for( int i = 0 ; i < n ; i ++ )
{
    if(a[i] == b)
    {
        s = i;
        yf = true;
        break;
    }
    cout << a[i] << ' ';
}

if(yf == true)
{
    for( int i = s + 1 ; i < n ; i ++ )
    {
    cout << a[i] << ' ';
    }
}  
 puts("");
}

return 0;

}