#include <iostream>
#define NMAX 50000
using namespace std;
void f(int lg, int a[])
{
int Max = 0, Min = 1 << 30;
for(int i=1; i<=lg; i++) {
if(a[i] & 1 && a[i] > Max) Max = i;
else if(a[i] < Min) Min = i;
else continue;
}
swap(a[Max], a[Min]);
}
int main()
{
int n, v[NMAX];
cin >> n;
for(int i=1; i<=n; i++) cin >> v[i];
cout << "\nVectorul nemodificat: ";
for(int i=1; i<=n; i++) cout << v[i] << ' ';
f(n, v);
cout << "\nVectorul modificat: ";
for(int i=1; i<=n; i++) cout << v[i] << ' ';
return 0;
}