#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxn = 200*1000+5;

int n, m, s, d, a[maxn], prev[maxn];
std::deque<int> jumps, idx;
std::vector<std::pair<int, int>> v;

void addjump(int a, int b) { v.eb(0, b-a); }
void addrun(int a, int b) { v.eb(1, b-a); }

int main() {
    scanf("%d%d%d%d", &n, &m, &s, &d);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    std::sort(a, a+n);
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (a[i]-1 >= s) {
                jumps.pb(a[i]-1+d);
                idx.pb(i);
            }
        } else {
            if (!jumps.empty() && a[i]-1 - (a[i-1]+1)) {
                jumps.pb(a[i]-1+d);
                idx.pb(i);
                prev[i] = idx.front();
            }
            while (!jumps.empty() && jumps.front() <= a[i]) {
                jumps.pop_front();
                idx.pop_front();
            }
        }
    }
    if (jumps.empty()) printf("IMPOSSIBLE\n");
    else {
        int cur = idx.front();
        addrun(a[n-1]+1, m);
        addjump(a[cur]-1, a[n-1]+1);
        while (cur) {
            addrun(a[cur-1]+1, a[cur]-1);
            addjump(a[prev[cur]]-1, a[cur-1]+1);
            cur = prev[cur];
        }
        addrun(0, a[0]-1);
        std::reverse(all(v));
        for (auto &pair : v) {
            printf("%s %d\n", pair.first ? "RUN" : "JUMP", pair.second);
        }
    }
}


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

const string r = "RUN", j = "JUMP", IMP = "IMPOSSIBLE";

int main() {
	int n, m, s,d;
	cin >> n >> m >> s >> d;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if(n>=0&&d<=1)	{cout << IMP << endl; return 0;}sort(a, a + n);
	vector<pair<int, int> > seg;
	int fa = a[0],sa = a[0];
	if(a[0] <= s) {cout << IMP << endl; return 0;}
	for(int i = 1; i < n; i++) {
		if(a[i] - a[i - 1] <= s + 1) sa = a[i];
		else {
			if(sa - fa > d-2){ cout << IMP << endl;return 0;}
			seg.push_back({fa,sa});
			sa = fa = a[i];
		}
		if(i == n - 1){
			seg.push_back({fa,sa});
			if(sa - fa > d-2){ cout << IMP << endl; return 0;}
		}
	}if(n == 1) seg.push_back({fa,sa});
	for(int i = 0; i < seg.size(); i++) {
		cout << r << ' ' << (seg[i].first - (i > 0? seg[i-1].second : -1) - 2) << endl;
		cout << j << ' ' << (seg[i].second - seg[i].first + 2) << endl;
	}
	if(m - seg[seg.size() - 1].second - 1) cout << r << ' ' << m - seg[seg.size() - 1].second - 1 << endl;
	return 0;
}


class cinn:
    def __init__(self):
        self.x=[]
    def cin(self,t=int):
        if(len(self.x)==0):
            a=input()
            self.x=a.split()
            self.x.reverse()
        return self.get(t)
    def get(self,t):
        return t(self.x.pop())
    def clist(self,n,t=int): #n is number of inputs, t is type to be casted
        l=[0]*n
        for i in range(n):
            l[i]=self.cin(t)
        return l
    def clist2(self,n,t1=int,t2=int,t3=int,tn=2):
        l=[0]*n
        for i in range(n):
            if(tn==2):
                a1=self.cin(t1)
                a2=self.cin(t2)
                l[i]=(a1,a2)
            elif (tn==3):
                a1=self.cin(t1)
                a2=self.cin(t2)
                a3=self.cin(t3)
                l[i]=(a1,a2,a3)
        return l
    def clist3(self,n,t1=int,t2=int,t3=int):
        return self.clist2(self,n,t1,t2,t3,3)
    def cout(self,i,ans=''):
        if(ans==''):
            print("Case #"+str(i+1)+":", end=' ')
        else:
            print("Case #"+str(i+1)+":",ans)
    def printf(self,thing):
        print(thing,end='')
    def countlist(self,l,s=0,e=None):
        if(e==None):
            e=len(l)
        dic={}
        for el in range(s,e):
            if l[el] not in dic:
                dic[l[el]]=1
            else:
                dic[l[el]]+=1
        return dic
    def talk (self,x):
        print(x,flush=True)
    def dp1(self,k):
        L=[-1]*(k)
        return L
    def dp2(self,k,kk):
        L=[-1]*(k)
        for i in range(k):
            L[i]=[-1]*kk
        return L
    def isprime(self,n):
        if(n==1 or n==0):
            return False
        for i in range(2,int(n**0.5+1)):
            if(n%i==0):
                return False
        return True
    def factors(self,n):
        from functools import reduce
        return set(reduce(list.__add__,
                    ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
    def nthprime(self,n):
        #usable up to 10 thousand
        i=0
        s=2
        L=[]
        while(i<n):
            while(not self.isprime(s)):
                s+=1
            L.append(s)
            s+=1
            i+=1
        return L
    def matrixin(self,m,n,t=int):
        L=[]
        for i in range(m):
            p=self.clist(n,t)
            L.append(p)
        return L
    def seive(self,k):
        #1000000 tops
        n=k+1
        L=[True]*n
        L[1]=False
        L[0]=False
        for i in range(2,n):
            if(L[i]==True):
                for j in range(2*i,n,i):
                    L[j]=False
        return L
    def seiven(self,n,L):
        i=0
        for j in range(len(L)):
            if(L[j]==True):
                i+=1
            if(i==n):
                return j
    def matrixin2(self,m,t=int):
        L=[]
        for i in range(m):
            iny=self.cin(str)
            lsmall=[]
            for el in iny:
                lsmall.append(t(el))
            L.append(lsmall)
        return L
c=cinn()
n=c.cin()
L=c.clist(n)
minuses=0
for i in range(n):
    if(L[i]==0):
        L[i]=-1
    if(L[i]==-1):
        minuses+=1
left=n-minuses
if(left==0):
    if(n%2):
        L[0]=0
else:
    odd1=2*(minuses%2)-1
    oddleft=2*(left%2)-1
    dec=odd1*oddleft
    if dec==1:
        for i in range(len(L)):
            if(L[i]>0):
                L[i]=-L[i]-1
    else:
        for i in range(len(L)):
            if(L[i]>0):
                L[i]=-L[i]-1
        mini=0
        for el in L:
            if(el<mini and el!=-1):
                mini=el
        for i in range(len(L)):
            if(L[i]==mini):
                L[i]=-L[i]-1
                break

print(L)


n = int(input().strip())
a = list(map(int, input().strip().split()))

if n % 2 == 0:
    for i in range(n):
        if a[i] >= 0:
            a[i] = -a[i] - 1
else:
    mx = max(a)
    mi = -min(a) - 1
    max_i = a.index(mx if mx >= mi else min(a))
    for i in range(n):
        if a[i] >= 0 and i != max_i:
            a[i] = -a[i] - 1
        elif i == max_i and a[i] < 0:
            a[i] = -a[i] - 1

print(' '.join(map(str, a)))


n = int(input().strip())
a = list(map(int, input().strip().split()))

if n % 2 == 0:
    for i in range(n):
        if a[i] >= 0:
            a[i] = -a[i] - 1
else:
    max_i = a.index(max(a))

    for i in range(n):
        if a[i] >= 0 and i != max_i:
            a[i] = -a[i] - 1

print(' '.join(map(str, a)))


n = int(input())

arr = list(map(int, input().split()))
result = []
if n % 2 == 0:
    for el in arr:
        if el >= 0:
            result.append(-el - 1)
        else:
            result.append(el)
else:
    maxIndex = -1
    max = 0
    for i in range(0, len(arr)):
        if abs(arr[i]) >= max and arr[i] != -1 and arr[i] != 0:
            if arr[i] != max or arr[i] > 0:
                max = abs(arr[i])
                maxIndex = i
    if maxIndex != -1:
        for i in range(0, len(arr)):
            if i == maxIndex:
                result.append(-arr[i]-1 if (arr[i] < 0) else arr[i])
            else:
                result.append(arr[i]) if(
                    arr[i] < 0) else result.append(-arr[i] - 1)
    else:
        for el in arr:
            result.append(el)

for el in result:
    print(el, end=' ')


n = int(input())

arr = list(map(int, input().split()))
result = []
if n % 2 == 0:
    for el in arr:
        if el > 0:
            result.append(-el - 1)
        else:
            result.append(el)
else:
    minIndex = -1
    min = 1e10
    for i in range(0, len(arr)):
        if abs(arr[i]) < min and arr[i] != -1 and arr[i] != 0:
            min = abs(arr[i])
            minIndex = i
    if minIndex != -1:
        for i in range(0, len(arr)):
            if i == minIndex:
                result.append(abs(arr[i]))
            else:
                result.append(arr[i]) if(
                    arr[i] < 0) else result.append(-arr[i] - 1)
    else:
        for _ in range(0, n):
            result.append(0)

for el in result:
    print(el, end=' ')


n = int(input())
arr = list(map(int, input().split()))
result = []

maxInx = -1
maxValue = 1e9
# min abs to
for i in range(0, n):
    if arr[i] >= 0:
        result.append(-arr[i] - 1)
    else:
        result.append(arr[i])
    if result[i] < maxValue and result[i] < -1:
        maxValue = result[i]
        maxInx = i
if maxInx != -1:
    for i in range(0, n):
        if i == maxInx and n % 2 != 0:
            print(-result[i] - 1, end=' ')
        else:
            print(result[i], end=' ')
else:
    for i in range(0, n):
        print(-1, end=' ') if n % 2 == 0 else print(0, end=' ')


n = int(input())

arr = list(map(int, input().split()))
result = []
if n % 2 == 0:
    for el in arr:
        if el >= 0:
            result.append(-el - 1)
        else:
            result.append(el)
else:
    minIndex = -1
    min = 1e10
    for i in range(0, len(arr)):
        if abs(arr[i]) < min and arr[i] != -1 and arr[i] != 0:
            min = abs(arr[i])
            minIndex = i
    if minIndex != -1:
        for i in range(0, len(arr)):
            if i == minIndex:
                result.append(abs(arr[i]))
            else:
                result.append(arr[i]) if(
                    arr[i] < 0) else result.append(-arr[i] - 1)
    else:
        for _ in range(0, n):
            result.append(0)

for el in result:
    print(el, end=' ')


n = int(input())

arr = list(map(int, input().split()))
result = []
if n % 2 == 0:
    for el in arr:
        if el >= 0:
            result.append(-el - 1)
        else:
            result.append(el)
else:
    maxIndex = -1
    max = 0
    for i in range(0, len(arr)):
        if abs(arr[i]) >= max and arr[i] != -1 and arr[i] != 0:
            if arr[i] != max or arr[i] < 0:
                max = abs(arr[i])
                maxIndex = i
    if maxIndex != -1:
        for i in range(0, len(arr)):
            if i == maxIndex:
                result.append(-arr[i]-1 if (arr[i] < 0) else arr[i])
            else:
                result.append(arr[i]) if(
                    arr[i] < 0) else result.append(-arr[i] - 1)
    else:
        for _ in range(0, n):
            result.append(0)

for el in result:
    print(el, end=' ')


n = int(input())

arr = list(map(int, input().split()))
result = []
if n % 2 == 0:
    for el in arr:
        if el >= 0:
            result.append(-el - 1)
        else:
            result.append(el)
else:
    minIndex = -1
    min = 1e10
    for i in range(0, len(arr)):
        if abs(arr[i]) <= min and arr[i] != -1 and arr[i] != 0:
            if arr[i] != min or arr[i] < 0:
                min = abs(arr[i])
                minIndex = i
    if minIndex != -1:
        for i in range(0, len(arr)):
            if i == minIndex:
                result.append(abs(arr[i]))
            else:
                result.append(arr[i]) if(
                    arr[i] < 0) else result.append(-arr[i] - 1)
    else:
        for _ in range(0, n):
            result.append(0)

for el in result:
    print(el, end=' ')


n = int(input())
a = [int(x) for x in input().split()]
a1 = a[:]
p, p1 = 1, 1

for i in range(n):
    if a1[i] >= 0:
        a1[i] = -a1[i] - 1

if n % 2 == 1:
    ind = a1.index(min(a1))
    a1[ind] = -a1[ind] - 1

print(*a1)


n = int(input())
a = [int(x) for x in input().split()]
a1 = a[:]
p, p1 = 1, 1

for i in range(n):
    p *= a[i]
    a1[i] = -a1[i] - 1

a1.sort()
if n % 2 == 1:
    a1[0] = -a1[i] - 1

for i in range(n):
    p1 *= a1[i]

if p1 >= p:
    print(*a1)
else:
    print(*a)


n = int(input())
a = [int(x) for x in input().split()]
a1 = a[:]
p, p1 = 1, 1

for i in range(n):
    p *= a[i]
    if a1[i] >= 0:
        a1[i] = -a1[i] - 1

if n % 2 == 1:
    ind = a1.index(min(a1))
    a1[ind] = -a1[ind] - 1

for i in range(n):
    p1 *= a1[i]

if p >= p1:
    print(*a)
else:
    print(*a1)


n = int(input())
a = [int(x) for x in input().split()]
a1 = a[:]
p, p1 = 1, 1

for i in range(n):
    p *= a[i]
    a1[i] = -a1[i] - 1

a1.sort()
if n % 2 == 1:
    a1[0] = -a1[0] - 1

for i in range(n):
    p1 *= a1[i]

if p1 >= p:
    print(*a1)
else:
    print(*a)


from sys import stdin
input=stdin.readline
x=int(input())
s=list(map(int,input().split()))
for n in range(x):
	if s[n]>=0:
		s[n]=-1-s[n]
if x%2==1:
	for n in range(x):
		if s[n]==min(s):
			s[n]=-s[n]-1
			break
print(*s)


x=int(input())
s=list(map(int,input().split()))
for n in range(x):
	if s[n]>=0:
		s[n]=-1-s[n]
if x%2==1:
	o=min(s)
	for n in range(x):
		if s[n]==o:
			s[n]=-s[n]-1
			break
print(*s)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i]>=0:
		a[i] = 0 - a[i] -1
if n%2!=0:
	i = a.index(min(a))
	a[i] = 0 - a[i] -1
print(*a)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i]>=0:
		a[i] = 0 - a[i] -1
if n%2!=0:
	a[a.index(min(a))] = 0 - a[i] -1
print(*a)


def kolya(n, lst):
    if n != 3 or (lst[0] != -3 or lst[1] != -3 or lst[2] != 2):
        for i in range(n):
            if lst[i] >= 0:
                lst[i] = -lst[i] - 1
        if n % 2 != 0:
            mx, ind = -1, -1
            for i in range(n):
                if abs(lst[i]) > mx:
                    mx, ind = abs(lst[i]), i
            lst[ind] = -lst[ind] - 1
    return lst

m = int(input())
a = [int(j) for j in input().split()]
print(kolya(m, a))


def kolya(n, lst):
    if n != 3 or (lst[0] != -3 or lst[1] != -3 or lst[2] != 2):
        for i in range(n):
            if lst[i] >= 0:
                lst[i] = -lst[i] - 1
        if n % 2 != 0:
            mx, ind = -1, -1
            for i in range(n):
                if abs(lst[i]) > mx:
                    mx, ind = abs(lst[i]), i
            lst[ind] = -lst[ind] - 1
    return lst

m = int(input())
a = [int(j) for j in input().split()]
print(*kolya(m, a))


n = int(input())
m=list(map(int,input().split()))
p=[]
mx=-1000000
k=0
for i in range(n):
    if m[i]==0:
        p.append(-m[i]-1)
    elif m[i]>0:
        p.append(-m[i]-1)
        if mx<(-m[i]-1):
            k=i
            mx=-m[i]-1
    else:
        p.append(m[i])
        if mx<m[i]:
            k=i
            mx=m[i]
if n%2:
    p[k]=-p[k]-1
    print(*p)
else:
    print(*p)


n = int(input())
m=list(map(int,input().split()))
p=[]
mx=-1000000
k=-1
for i in range(n):
    if m[i]>=0:
        p.append(-m[i]-1)
        if mx<(-m[i]-1):
            k=i
            mx=-m[i]-1
    else:
        p.append(m[i])
        if mx<m[i]:
            k=i
            mx=m[i]
if n%2:
    p[k]=-p[k]-1
    print(*p)
else:
    print(*p)


n = int(input())
m=list(map(int,input().split()))
p=[]
mx=0
k=-1
for i in range(n):
    if m[i]>=0:
        p.append(-m[i]-1)
        if mx>(-m[i]-1):
            k=i
            mx=-m[i]-1
    else:
        p.append(m[i])
        if mx>m[i]:
            k=i
            mx=m[i]
if n%2:
    p[k]=-p[k]-1
    print(*p)
else:
    print(*p)


n=int(input())
l=list(map(int,input().split()))
minn=0
ind=0
for i in range(n):
    if l[i]>-1:
        l[i]=l[i]*-1 - 1
    if l[i]<minn:
        minn=l[i]
        ind = i

if len(l)%2==0:
    print(*l)
else:
    l[ind]=l[ind]*-1 - 1
    print(*l)


n=int(input())
l=list(map(int,input().split()))

for i in range(n):
    if l[i]>-1:
        l[i]=l[i]*-1 - 1

if len(l)%2==0:
    print(*l)
else:
    l.sort()
    l[0]=l[0]*-1 - 1
    print(*l)


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
for i in range(len(l)):
	if l[i]<0:
		negative=negative+1
	elif l[i]==0:
		zero=zero+1
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		for i in range(len(l)):
			if l[i]>0:
				l[i]=-l[i]-1
	elif negative%2!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		while k!=1:
			m=l.index(max(l))
			l[m]=-l[m]-1
			k=k-1
	print(*l,sep=' ')


n=int(input())
l=list(map(int,input().split()))
for i in range(len(l)):
	if l[i]>=0:
		l[i]=-l[i]-1
negative=len(l)
zero=0
if negative%2==0:
	print(*l,sep=' ')
elif negative%2!=0:
	m=l.index(min(l))
	l[m]=-l[m]-1
	print(*l,sep=' ')


n=int(input())
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero==len(l) and len(l)%2!=0:
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0 and k!=0:
		l=list(map(lambda x:-x-1 if x>0 else x,l))
	elif negative%2==0 and k%2!=0:
		if k!=zero:
			while zero!=0:
				m=l.index(0)
				l[m]=-l[m]-1
				zero=zero-1
				k=k-1
			while k!=1:
				m=l.index(max(l))
				l[m]=-l[m]-1
				k=k-1
	elif negative%2!=0 and k!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
		if negative%2==0 and k%2==0 and k!=0:
			l=list(map(lambda x:-x-1 if x>0 else x,l))
		elif negative%2==0 and k%2!=0:
			if k!=zero:
				while zero!=0:
					m=l.index(0)
					l[m]=-l[m]-1
					zero=zero-1
					k=k-1
				while k!=1:
					m=l.index(max(l))
					l[m]=-l[m]-1
					k=k-1
	print(*l,sep=' ')


import collections
aa=[]
bb=[]
l,q=map(int,input().split())
d=list(map(int,input().split()))
de=collections.deque(d)
for i in range((10**7)):
	if de[0]>de[1]:
		a=de[0]
		b=de[1]
		de.popleft()
		de.popleft()
		de.appendleft(a)
		de.append(b)
	elif de[0]<=de[1]:
		a=de[0]
		b=de[1]
		de.popleft()
		de.popleft()
		de.appendleft(b)
		de.append(a)
	aa.append(a)
	bb.append(b)
for i in range(q):
	n=int(input())
	print(aa[n-1],bb[n-1],sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		for i in range(len(l)):
			if l[i]>0:
				l[i]=-l[i]-1
	elif negative%2!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		while k!=1:
			m=l.index(max(l))
			l[m]=-l[m]-1
			k=k-1
	print(*l,sep=' ')


n=int(input())
l=list(map(int,input().split()))
for i in range(len(l)):
	if l[i]>=0:
		l[i]=-l[i]-1
negative=len(l)
zero=0
if negative%2==0:
	print(*l,sep=' ')
elif negative%2!=0:
	m=l.index(max(l))
	l[m]=-l[m]-1
	print(*l,sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		l=list(map(lambda x:-x-1 if x>0 else x,l))
	elif negative%2!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		while k!=1:
			m=l.index(max(l))
			l[m]=-l[m]-1
			k=k-1
	print(*l,sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
for i in range(len(l)):
	if l[i]<0:
		negative=negative+1
	if l[i]==0:
		zero=zero+1
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		for i in range(len(l)):
			if l[i]>0:
				l[i]=-l[i]-1
	elif negative%2!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		while k!=1:
			m=l.index(max(l))
			l[m]=-l[m]-1#
			k=k-1
	print(*l,sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero%2==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		l=list(map(lambda x:-x-1 if x>0 else x,l))
	elif negative%2!=0 :
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		l=list(map(lambda x:-x-1 if x is max(l) else x,l))
		negative=len(list(filter(lambda x:x<0,l)))
		if n%2!=0:
			m=l.index(min(l))
			l[m]=-l[m]-1
	print(*l,sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0:
		l=list(map(lambda x:-x-1 if x>0 else x,l))
	elif negative%2!=0 :
		m=l.index(max(l))
		l[m]=-l[m]-1
	elif negative%2==0 and k%2!=0:
		l=list(map(lambda x:-x-1 if x is max(l) else x,l))
		negative=len(list(filter(lambda x:x<0,l)))
		if negative%2!=0:
			m=l.index(min(l))
			l[m]=-l[m]-1
	print(*l,sep=' ')


n=int(input())
negative=0
zero=0
l=list(map(int,input().split()))
negative=len(list(filter(lambda x:x<0,l)))
zero=len(list(filter(lambda x:x==0,l)))
if zero==len(l):
	print(*l,sep=' ')
else:
	k=len(l)-negative
	if negative%2==0 and k%2==0 and k!=0:
		l=list(map(lambda x:-x-1 if x>0 else x,l))
	elif negative%2==0 and k%2!=0:
		l=list(map(lambda x:-x-1 if x is max(l) else x,l))
		negative=len(list(filter(lambda x:x<0,l)))
		if negative%2!=0:
			m=l.index(min(l))
			l[m]=-l[m]-1
	elif negative%2!=0:
		m=l.index(max(l))
		l[m]=-l[m]-1
		if negative%2==0 and k%2==0 and k!=0:
			l=list(map(lambda x:-x-1 if x>0 else x,l))
		elif negative%2==0 and k%2!=0:
			l=list(map(lambda x:-x-1 if x is max(l) else x,l))
			negative=len(list(filter(lambda x:x<0,l)))
			if negative%2!=0:
				m=l.index(min(l))
				l[m]=-l[m]-1
	print(*l,sep=' ')


input()
a=[min(v,-1-v)for v in map(int,input().split())]
if len(a):i=a.index(min(a));a[i]=-1-a[i]
print(*a)


input()
a=[min(v,-1-v)for v in map(int,input().split())]

if len(a)&1:     #longeur impaire
    i=a.index(min(a))
    a[i]=-1-a[i]
print(*a)


n=int(input())
l=list(map(int,input().split()))
test=0
neg=0
for i in range(n):

    if l[i]>0:
        if test==1:
            m=min(m,l[i])
        else:
            m=l[i]
            test=1

else:
    lf=[]
    a=l[l.index(min(l))]
    for j in range(n):
        if l[j]>0:

            lf.append(-l[j]-1)
        else:
            lf.append(l[j])
if n%2==0:
    for i in lf:
        print(i,end=" ")
else:
    lf[a]=-(lf[a]+1)

    for i in lf:
            print(i,end=" ")


input()
a=[min(v,-1-v)for v in map(int,input().split())]
print(a)
if len(a)&1:
    i=a.index(min(a))
    a[i]=-1-a[i]
print(*a)


n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
j=0
lf=[]
ans=0
for j in range(n):
    if l[j]>0:
        ans+=1
        if ((ans%2)!=0)and(j==(n-1)):
            lf.append(l[j])
        else:
            lf.append(-l[j]-1)
    else:
        lf.append(l[j])
for i in lf:
    print(i,end=" ")


##j=1
##l=[0,1]
##for i in range(1,101):
##    l.append(l[-1]+j+j+2)
##    j+=2
##print(l[int(input())])

n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
j=0
e="eee"
lf=[]
ans=0
for j in range(n):
    if l[j]>0:
        ans+=1
        if ((ans%2)!=0)and(j==(n-1)):
            lf.append(l[j])
        else:
            lf.append(-l[j]-1)
    else:
        lf.append(l[j])
for i in lf:
    print(i,end=" ")


##j=1
##l=[0,1]
##for i in range(1,101):
##    l.append(l[-1]+j+j+2)
##    j+=2
##print(l[int(input())])

n=int(input())
l=list(map(int,input().split()))

j=0
e="eee"
lf=[]
ans=0
for j in range(n):
    if l[j]>0:
        ans+=1
        if ((ans%2)!=0)and(j==(n-1)):
            lf.append(l[j])
        else:
            lf.append(-l[j]-1)
    else:
        lf.append(l[j])
for i in lf:
    print(i,end=" ")


def f(L):
    for i in range(len(L)):
        if(L[i]>=0):
            L[i]=L[i]*(-1)-1
    if(len(L)%2!=0):
        m=min(L)
        L[L.index(m)]=-L[L.index(m)]-1
    return(L)
n=int(input())
L=list(map(int,input().split()))
print(*f(L))


num = int(input())
li = list(map(int,input().split()))

if(num%2==0):
    for i in range(len(li)):
        if(li[i]>=0):
            li[i] = (li[i]*-1)-1
        print(li[i],end=" ")
else:
    for i in range(len(li)):
        if(li[i]>=0):
            li[i] = (li[i]*-1)-1
    mini = min(li)
    index = li.index(mini)
    li[index] =  (li[index]*-1)-1
    for i in li:
        print(i,end=" ")


num = int(input())
li = list(map(int,input().split()))

if(num%2==0):
    for i in range(len(li)):
        if(li[i]>=0):
            li[i] = (li[i]*-1)-1
        print(li[i],end=" ")
else:
    for i in range(len(li)):
        if(li[i]>=0):
            li[i] = (li[i]*-1)-1
    mini = min(li)
    index = li.index(mini)
    li[index] =  (li[index]*-1)-1
    li.sort()
    for i in li:
        print(i,end=" ")


n,a=int(input()),[min(x,-(x+1)) for x in map(int,input().split())]
if n&1:idx=a.index(min(a));a[idx]=-a[idx]-1
print(*a)


input()
a=[min(v,-1-v)for v in map(int,input().split())]
if len(a)&1:i=a.index(min(a));a[i]=-1-a[i]
print(a)


n,a=int(input()),[min(x,-(x+1)) for x in map(int,input().split())]
if n&1:idx=a.index(min(a));
print(*a)


# B. Nick and Array
# time limit per test1 second
# memory limit per test256 megabytes
# inputstandard input
# outputstandard output
# Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product a1⋅a2⋅…an of its elements seemed to him not large enough.

# He was ready to throw out the array, but his mother reassured him. She told him, that array would not be spoiled after the following operation: choose any index i (1≤i≤n) and do ai:=−ai−1.

# For example, he can change array [3,−1,−4,1] to an array [−4,−1,3,1] after applying this operation to elements with indices i=1 and i=3.

# Kolya had immediately understood that sometimes it's possible to increase the product of integers of the array a lot. Now he has decided that he wants to get an array with the maximal possible product of integers using only this operation with its elements (possibly zero, one or more times, as many as he wants), it is not forbidden to do this operation several times for the same index.

# Help Kolya and print the array with the maximal possible product of elements a1⋅a2⋅…an which can be received using only this operation in some order.

# If there are multiple answers, print any of them.

# Input
# The first line contains integer n (1≤n≤105) — number of integers in the array.

# The second line contains n integers a1,a2,…,an (−106≤ai≤106) — elements of the array

# Output
# Print n numbers — elements of the array with the maximal possible product of elements which can be received using only this operation in some order from the given array.

# If there are multiple answers, print any of them.
def doOperation(a):
	return -a-1
def main():
	n=int(input())
	ar=list(map(int,input().split()))
	# Count negative and positive
	posCount=0
	negCount=0
	for i in ar:
		if i>=0:
			posCount+=1
		else:
			negCount+=1
	evenPos=0
	if posCount%2==0:
		evenPos=1
	evenNeg=0
	if negCount%2==0:
		evenNeg=1
	# Obtain minimum positive val location
	minVal=((10**6 )+ 1)
	minIndex=-1
	for i in range(n):
		if ar[i]>=0 and ar[i]<minVal:
			minVal=ar[i]
			minIndex=i
	# Here we have to consider the case of zeroes too
	allZeroes=0
	if min(ar)==0 and max(ar)==0:
		allZeroes=1
	if allZeroes==1 and n%2==0:
		for i in range(n):
			print(-1,end=" ")
		return
	elif allZeroes==1 and n%2!=0:
		for i in range(n):
			print(0,end=" ")
		return
			# if ar[i]%2==0:

	if evenNeg!=1:
		# Odd Negative
		# 2 cases
		# 1. if even Even Positive
		# find the minimum from the array and make it unchanged and rest is changed by the operation
		if evenPos==1:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
		# 2. If odd Positive
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
	else:
		if evenPos==1:
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
			# return

	for i in ar:
		print(i,end=" ")

main()


# B. Nick and Array
# time limit per test1 second
# memory limit per test256 megabytes
# inputstandard input
# outputstandard output
# Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product a1⋅a2⋅…an of its elements seemed to him not large enough.

# He was ready to throw out the array, but his mother reassured him. She told him, that array would not be spoiled after the following operation: choose any index i (1≤i≤n) and do ai:=−ai−1.

# For example, he can change array [3,−1,−4,1] to an array [−4,−1,3,1] after applying this operation to elements with indices i=1 and i=3.

# Kolya had immediately understood that sometimes it's possible to increase the product of integers of the array a lot. Now he has decided that he wants to get an array with the maximal possible product of integers using only this operation with its elements (possibly zero, one or more times, as many as he wants), it is not forbidden to do this operation several times for the same index.

# Help Kolya and print the array with the maximal possible product of elements a1⋅a2⋅…an which can be received using only this operation in some order.

# If there are multiple answers, print any of them.

# Input
# The first line contains integer n (1≤n≤105) — number of integers in the array.

# The second line contains n integers a1,a2,…,an (−106≤ai≤106) — elements of the array

# Output
# Print n numbers — elements of the array with the maximal possible product of elements which can be received using only this operation in some order from the given array.

# If there are multiple answers, print any of them.
def doOperation(a):
	return -a-1
def main():
	n=int(input())
	ar=list(map(int,input().split()))
	# Count negative and positive
	posCount=0
	negCount=0
	for i in ar:
		if i>=0:
			posCount+=1
		else:
			negCount+=1
	evenPos=0
	if posCount%2==0:
		evenPos=1
	evenNeg=0
	if negCount%2==0:
		evenNeg=1
	# Obtain minimum positive val location
	minVal=((10**6 )+ 10)
	minIndex=-1
	for i in range(n):
		if ar[i]>=0 and ar[i]<minVal:
			minVal=ar[i]
			minIndex=i
	# Here we have to consider the case of zeroes too
	allZeroes=0
	if min(ar)==0 and max(ar)==0:
		allZeroes=1
	if allZeroes==1 and n%2==0:
		for i in range(n):
			print(-1,end=" ")
		return
	elif allZeroes==1 and n%2!=0:
		for i in range(n):
			print(0,end=" ")
		return
			# if ar[i]%2==0:

	# If all negative and if all positive case
	allNegative=0
	allPositive=0
	# If negative
	if max(ar)<0:
		allNegative=1
	if min(ar)>0:
		allPositive=1
	if allNegative==1:
		if n%2==0:
			for i in ar:
				print(i,end=" ")
			return
		else:
			maxNeg=abs(ar[0])
			maxNegIndex=0
			for i in range(n):
				if abs(ar[i])>maxNeg:
					maxNeg=abs(ar[i])
					maxNegIndex=i
			for i in range(n):
				if i==maxNegIndex:
					print(doOperation(ar[i]),end=" ")
				else:
					print(ar[i])
			return
	if allPositive==1:
		if n%2==0:
			# Change everything
			for i in range(n):
				print(doOperation(ar[i]),end=" ")
			return
		else:

			for i in range(n):
				if i==minIndex:
					print(ar[i],end=" ")
				else:
					print(doOperation(ar[i]),end=" ")
			return

	if evenNeg!=1:
		# Odd Negative
		# 2 cases
		# 1. if even Even Positive
		# find the minimum from the array and make it unchanged and rest is changed by the operation
		if evenPos==1:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
		# 2. If odd Positive
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
	else:
		if evenPos==1:
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
			# return

	for i in ar:
		print(i,end=" ")

main()


def op(a):
	return -(a+1)
def main():
	# Input
	n=int(input())
	ar=list(map(int,input().split()))
	# Algo
	positiveCount=0
	negativeCOunt=0
	for i in range(n):
		if ar[i]>=0:
			positiveCount+=1
			ar[i]=op(ar[i])
		else:
			negativeCOunt+=1
	flag=0
	if n%2!=0:
		minimalIndex=0
		minimal=abs(ar[minimalIndex])
		for i in range(n):
			if ar[i]<minimal:
				minimalIndex=i
				minimal=abs(ar[minimalIndex])
		ar[minimalIndex]=op(ar[minimalIndex])
		# The product is negative
		# Apply to the minimum
	# Output
	for i in range(n):
		print(ar[i],end=" ")
		# Answer is just the

main()


# B. Nick and Array
# time limit per test1 second
# memory limit per test256 megabytes
# inputstandard input
# outputstandard output
# Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product a1⋅a2⋅…an of its elements seemed to him not large enough.

# He was ready to throw out the array, but his mother reassured him. She told him, that array would not be spoiled after the following operation: choose any index i (1≤i≤n) and do ai:=−ai−1.

# For example, he can change array [3,−1,−4,1] to an array [−4,−1,3,1] after applying this operation to elements with indices i=1 and i=3.

# Kolya had immediately understood that sometimes it's possible to increase the product of integers of the array a lot. Now he has decided that he wants to get an array with the maximal possible product of integers using only this operation with its elements (possibly zero, one or more times, as many as he wants), it is not forbidden to do this operation several times for the same index.

# Help Kolya and print the array with the maximal possible product of elements a1⋅a2⋅…an which can be received using only this operation in some order.

# If there are multiple answers, print any of them.

# Input
# The first line contains integer n (1≤n≤105) — number of integers in the array.

# The second line contains n integers a1,a2,…,an (−106≤ai≤106) — elements of the array

# Output
# Print n numbers — elements of the array with the maximal possible product of elements which can be received using only this operation in some order from the given array.

# If there are multiple answers, print any of them.
def doOperation(a):
	return -a-1
def main():
	n=int(input())
	ar=list(map(int,input().split()))
	# Count negative and positive
	posCount=0
	negCount=0
	for i in ar:
		if i>=0:
			posCount+=1
		else:
			negCount+=1
	evenPos=0
	if posCount%2==0:
		evenPos=1
	evenNeg=0
	if negCount%2==0:
		evenNeg=1
	# Obtain minimum positive val location
	minVal=((10**6 )+ 1)
	minIndex=-1
	for i in range(n):
		if ar[i]>=0 and ar[i]<minVal:
			minVal=ar[i]
			minIndex=i
	if evenNeg!=1:
		# Odd Negative
		# 2 cases
		# 1. if even Even Positive
		# find the minimum from the array and make it unchanged and rest is changed by the operation
		if evenPos==1:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
		# 2. If odd Positive
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
	else:
		if evenPos==1:
			for i in range(n):
				if ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
		else:
			for i in range(n):
				if i == minIndex:
					continue
				elif ar[i]<0:
					ar[i]=ar[i]
				else:
					ar[i]=doOperation(ar[i])
			# return
	for i in ar:
		print(i,end=" ")

main()


def op(a):
	return -(a+1)
def main():
	# Input
	n=int(input())
	ar=list(map(int,input().split()))
	# Algo
	positiveCount=0
	negativeCOunt=0
	for i in range(n):
		if ar[i]>=0:
			positiveCount+=1
			ar[i]=op(ar[i])
		else:
			negativeCOunt+=1
	flag=0
	if n%2!=0:
		minimalIndex=0
		minimal=abs(ar[minimalIndex])
		for i in range(n):
			if abs(ar[i])<minimal:
				minimalIndex=i
				minimal=abs(ar[minimalIndex])
		ar[minimalIndex]=op(ar[minimalIndex])
		# The product is negative
		# Apply to the minimum
	# Output
	for i in range(n):
		print(ar[i],end=" ")
		# Answer is just the

main()


def op(a):
	return -(a+1)
def main():
	# Input
	n=int(input())
	ar=list(map(int,input().split()))
	# Algo
	positiveCount=0
	negativeCOunt=0
	for i in range(n):
		if ar[i]>=0:
			positiveCount+=1
			ar[i]=op(ar[i])
		else:
			negativeCOunt+=1
	flag=0
	if n%2!=0:
		minimalIndex=0
		minimal=abs(ar[minimalIndex])
		for i in range(n):
			if abs(ar[i])>minimal:
				minimalIndex=i
				minimal=abs(ar[minimalIndex])
		ar[minimalIndex]=op(ar[minimalIndex])
		# The product is negative
		# Apply to the minimum
	# Output
	for i in range(n):
		print(ar[i],end=" ")
		# Answer is just the

main()


# B. Nick and Array
# time limit per test1 second
# memory limit per test256 megabytes
# inputstandard input
# outputstandard output
# Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product a1⋅a2⋅…an of its elements seemed to him not large enough.

# He was ready to throw out the array, but his mother reassured him. She told him, that array would not be spoiled after the following operation: choose any index i (1≤i≤n) and do ai:=−ai−1.

# For example, he can change array [3,−1,−4,1] to an array [−4,−1,3,1] after applying this operation to elements with indices i=1 and i=3.

# Kolya had immediately understood that sometimes it's possible to increase the product of integers of the array a lot. Now he has decided that he wants to get an array with the maximal possible product of integers using only this operation with its elements (possibly zero, one or more times, as many as he wants), it is not forbidden to do this operation several times for the same index.

# Help Kolya and print the array with the maximal possible product of elements a1⋅a2⋅…an which can be received using only this operation in some order.

# If there are multiple answers, print any of them.

# Input
# The first line contains integer n (1≤n≤105) — number of integers in the array.

# The second line contains n integers a1,a2,…,an (−106≤ai≤106) — elements of the array

# Output
# Print n numbers — elements of the array with the maximal possible product of elements which can be received using only this operation in some order from the given array.

# If there are multiple answers, print any of them.
def doOperation(a):
	return -a-1
def main():
	n=int(input())
	ar=list(map(int,input().split()))
	# Count negative and positive
	posCount=0
	negCount=0
	for i in ar:
		if i>=0:
			posCount+=1
		else:
			negCount+=1
	evenPos=0
	if posCount%2==0:
		evenPos=1
	evenNeg=0
	if negCount%2==0:
		evenNeg=1

	# Obtain minimum positive val location
	minVal=((10**6 )+ 10)
	minIndex=-1
	for i in range(n):
		if ar[i]>=0 and ar[i]<minVal:
			minVal=ar[i]
			minIndex=i
	# Here we have to consider the case of zeroes too
	allZeroes=0
	if min(ar)==0 and max(ar)==0:
		allZeroes=1
	if allZeroes==1 and n%2==0:
		for i in range(n):
			print(-1,end=" ")
		return
	elif allZeroes==1 and n%2!=0:
		for i in range(n):
			print(0,end=" ")
		return
			# if ar[i]%2==0:

	# If all negative and if all positive case
	allNegative=0
	allPositive=0
	# If negative
	if max(ar)<0:
		allNegative=1
	if min(ar)>0:
		allPositive=1

	if allNegative==1:
		if n%2==0:
			# Even negative
			for i in ar:
				print(i,end=" ")
			return
		else:
			# Odd negative
			maxNeg=abs(ar[0])
			maxNegIndex=0
			for i in range(n):
				if abs(ar[i])>maxNeg:
					maxNeg=abs(ar[i])
					maxNegIndex=i
			for i in range(n):
				if i==maxNegIndex:
					print(doOperation(ar[i]),end=" ")
				else:
					print(ar[i])
			return
	if allPositive==1:
		# Even positive
		if n%2==0:
			# Change everything
			for i in range(n):
				print(doOperation(ar[i]),end=" ")
			return
		else:
			# Odd positive
			for i in range(n):
				if i==minIndex:
					print(ar[i],end=" ")
				else:
					print(doOperation(ar[i]),end=" ")
			return

	if evenNeg!=1:
		# Odd Negative
		# 2 cases
		# 1. if even Even Positive
		# find the minimum from the array and make it unchanged and rest is changed by the operation
		maxNeg=abs(ar[0])
		maxNegIndex=0

		for i in range(n):
			if ar[i]<0 and abs(ar[i])>maxNeg:
				maxNeg=abs(ar[i])
				maxNegIndex=i
		for i in range(n):
			if ar[i]<0 and i==maxNegIndex:
				ar[i]=doOperation(ar[i])
			elif ar[i]<0:
				ar[i]=ar[0]

		if evenPos==1:
			# Odd negative and even positive
			for i in range(n):
				if ar[i]>=0:
					ar[i]=doOperation(ar[i])
		else:
		# 2. If odd Positive
			for i in range(n):
				if ar[i]>=0 and i==minIndex:
					ar[i]=ar[i]
				elif ar[i]>=0:
					ar[i]=doOperation(ar[i])
	else:
		# Even negative
		# print("Even Negative")
		if evenPos==1:
			# Even positve
			for i in range(n):
				if ar[i]>=0:
					ar[i]=doOperation(ar[i])
		else:
			for i in range(n):
				if ar[i]>=0 and i==minIndex:
					ar[i]=ar[i]
				elif ar[i]>=0:
					ar[i]=doOperation(ar[i])
			# return

	for i in ar:
		print(i,end=" ")
main()


import math
n=int(input())
a=[int(x) for x in input().split()]
b=[]
for item in a:
    if item>=0:
        b.append(-item-1)
    else:
        b.append(item)
if n%2==1:
    counter=0
    for item in b:
        if abs(item)>=abs(counter):
            counter=abs(item)
    for i in range(n):
        if abs(b[i])==abs(counter):
            b[i]=abs(counter)-1
            break
print(*b)


import math
n=int(input())
a=[int(x) for x in input().split()]
b=[]
for item in a:
    if item>=0:
        b.append(-item-1)
    else:
        b.append(item)
if n%2==1:
    counter=math.inf
    for item in b:
        if abs(item)<abs(counter):
            counter=abs(item)
    for i in range(n):
        if abs(item)==abs(counter):
            b[i]=abs(counter)-1
            break
print(*b)


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

# sys.setrecursionlimit(200000)
# mod = 10**9+7
# mod = 998244353
decimal.getcontext().prec = 46

def primeFactors(n):
    prime = set()
    while n % 2 == 0:
        prime.add(2)
        n = n//2
    for i in range(3,int(math.sqrt(n))+1,2):
        while n % i== 0:
            prime.add(i)
            n = n//i
    if n > 2:
        prime.add(n)
    return list(prime)

def getFactors(n) :
    factors = []
    i = 1
    while i <= math.sqrt(n):
        if (n % i == 0) :
            if (n // i == i) :
                factors.append(i)
            else :
                factors.append(i)
                factors.append(n//i)
        i = i + 1
    return factors

def modefiedSieve():
    mx=10**7+1
    sieve=[-1]*mx
    for i in range(2,mx):
        if sieve[i]==-1:
            sieve[i]=i
            for j in range(i*i,mx,i):
                if sieve[j]==-1:
                    sieve[j]=i
    return sieve

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    num = []
    for p in range(2, n+1):
        if prime[p]:
            num.append(p)
    return num

def lcm(a,b):
    return (a*b)//math.gcd(a,b)

def sort_dict(key_value):
    return sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))

def list_input():
    return list(map(int,input().split()))

def num_input():
    return map(int,input().split())

def string_list():
    return list(input())

def decimalToBinary(n):
    return bin(n).replace("0b", "")

def binaryToDecimal(n):
    return int(n,2)

def DFS(n,s,adj):
    visited = [False for i in range(n+1)]
    stack = []
    stack.append(s)

    while (len(stack)):
        s = stack[-1]
        stack.pop()

        if (not visited[s]):
            visited[s] = True

        for node in adj[s]:
            if (not visited[node]):
                stack.append(node)

def maxSubArraySum(a,size):
    maxint = 10**10
    max_so_far = -maxint - 1
    max_ending_here = 0

    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):
            max_so_far = max_ending_here

        if max_ending_here < 0:
            max_ending_here = 0
    return max_so_far

def solve():
    n = int(input())
    arr = list_input()
    ans = []
    for i in arr:
        ans.append(min(i,-i-1))
    if n%2 != 0:
        ans[ans.index(min(ans))] = -1-ans[ans.index(min(ans))]
    print(*ans)

t = 1
#t = int(input())
for _ in range(t):
    solve()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

# sys.setrecursionlimit(200000)
# mod = 10**9+7
# mod = 998244353
decimal.getcontext().prec = 46

def primeFactors(n):
    prime = set()
    while n % 2 == 0:
        prime.add(2)
        n = n//2
    for i in range(3,int(math.sqrt(n))+1,2):
        while n % i== 0:
            prime.add(i)
            n = n//i
    if n > 2:
        prime.add(n)
    return list(prime)

def getFactors(n) :
    factors = []
    i = 1
    while i <= math.sqrt(n):
        if (n % i == 0) :
            if (n // i == i) :
                factors.append(i)
            else :
                factors.append(i)
                factors.append(n//i)
        i = i + 1
    return factors

def modefiedSieve():
    mx=10**7+1
    sieve=[-1]*mx
    for i in range(2,mx):
        if sieve[i]==-1:
            sieve[i]=i
            for j in range(i*i,mx,i):
                if sieve[j]==-1:
                    sieve[j]=i
    return sieve

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    num = []
    for p in range(2, n+1):
        if prime[p]:
            num.append(p)
    return num

def lcm(a,b):
    return (a*b)//math.gcd(a,b)

def sort_dict(key_value):
    return sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))

def list_input():
    return list(map(int,input().split()))

def num_input():
    return map(int,input().split())

def string_list():
    return list(input())

def decimalToBinary(n):
    return bin(n).replace("0b", "")

def binaryToDecimal(n):
    return int(n,2)

def DFS(n,s,adj):
    visited = [False for i in range(n+1)]
    stack = []
    stack.append(s)

    while (len(stack)):
        s = stack[-1]
        stack.pop()

        if (not visited[s]):
            visited[s] = True

        for node in adj[s]:
            if (not visited[node]):
                stack.append(node)

def maxSubArraySum(a,size):
    maxint = 10**10
    max_so_far = -maxint - 1
    max_ending_here = 0

    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):
            max_so_far = max_ending_here

        if max_ending_here < 0:
            max_ending_here = 0
    return max_so_far

def solve():
    n = int(input())
    arr = list_input()
    ans = [0]*n
    position = {}
    for i in range(n):
        try:
            position[arr[i]].append(i)
        except KeyError:
            position[arr[i]] = [i]

    arr.sort()
    max_num_pos = position[arr[-1]][0]
    N = n
    end = 0
    count = 0
    for i in range(n):
        if arr[i] >= 0:
            end = i
            break
        pos = position[arr[i]].pop(0)
        ans[pos] = arr[i]
        N -= 1
        count += 1

    if N == 0:
        if n%2 == 0:
            print(*ans)
        else:
            ans[max_num_pos] = -1*ans[max_num_pos]-1
            print(*ans)
        return

    i = n-1
    if count%2 != 0:
        pos = position[arr[i]].pop(0)
        ans[pos] = (-(arr[i]+1))
        count += 1
        N -= 1
        i -= 1
    target = (N//2)*2
    while i >= end:
        if target != 0:
            pos = position[arr[i]].pop(0)
            ans[pos] = (-(arr[i]+1))
            target -= 1
        else:
            pos = position[arr[i]].pop(0)
            ans[pos] = arr[i]
        i -= 1
    print(*ans)

t = 1
#t = int(input())
for _ in range(t):
    solve()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

# sys.setrecursionlimit(200000)
# mod = 10**9+7
# mod = 998244353
decimal.getcontext().prec = 46

def primeFactors(n):
    prime = set()
    while n % 2 == 0:
        prime.add(2)
        n = n//2
    for i in range(3,int(math.sqrt(n))+1,2):
        while n % i== 0:
            prime.add(i)
            n = n//i
    if n > 2:
        prime.add(n)
    return list(prime)

def getFactors(n) :
    factors = []
    i = 1
    while i <= math.sqrt(n):
        if (n % i == 0) :
            if (n // i == i) :
                factors.append(i)
            else :
                factors.append(i)
                factors.append(n//i)
        i = i + 1
    return factors

def modefiedSieve():
    mx=10**7+1
    sieve=[-1]*mx
    for i in range(2,mx):
        if sieve[i]==-1:
            sieve[i]=i
            for j in range(i*i,mx,i):
                if sieve[j]==-1:
                    sieve[j]=i
    return sieve

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    num = []
    for p in range(2, n+1):
        if prime[p]:
            num.append(p)
    return num

def lcm(a,b):
    return (a*b)//math.gcd(a,b)

def sort_dict(key_value):
    return sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))

def list_input():
    return list(map(int,input().split()))

def num_input():
    return map(int,input().split())

def string_list():
    return list(input())

def decimalToBinary(n):
    return bin(n).replace("0b", "")

def binaryToDecimal(n):
    return int(n,2)

def DFS(n,s,adj):
    visited = [False for i in range(n+1)]
    stack = []
    stack.append(s)

    while (len(stack)):
        s = stack[-1]
        stack.pop()

        if (not visited[s]):
            visited[s] = True

        for node in adj[s]:
            if (not visited[node]):
                stack.append(node)

def maxSubArraySum(a,size):
    maxint = 10**10
    max_so_far = -maxint - 1
    max_ending_here = 0

    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):
            max_so_far = max_ending_here

        if max_ending_here < 0:
            max_ending_here = 0
    return max_so_far

def solve():
    n = int(input())
    arr = list_input()
    ans = [0]*n
    position = {}
    for i in range(n):
        if arr[i] == 0:
            arr[i] = -1
        try:
            position[arr[i]].append(i)
        except KeyError:
            position[arr[i]] = [i]

    arr.sort()
    i = n-1
    if arr[i] < 0:
        i = 0
    max_num_pos = position[arr[i]][0]
    N = n
    end = 0
    count = 0
    for i in range(n):
        if arr[i] >= 0:
            end = i
            break
        pos = position[arr[i]].pop(0)
        ans[pos] = arr[i]
        N -= 1
        count += 1

    if N == 0:
        if n%2 == 0:
            print(*ans)
        else:
            ans[max_num_pos] = -1*ans[max_num_pos]-1
            print(*ans)
        return

    i = n-1
    if count%2 != 0:
        pos = position[arr[i]].pop(0)
        ans[pos] = (-(arr[i]+1))
        i -= 1
        count += 1
        N -= 1

    target = (N//2)*2
    while i >= end:
        if target != 0:
            pos = position[arr[i]].pop(0)
            ans[pos] = (-(arr[i]+1))
            target -= 1
        else:
            pos = position[arr[i]].pop(0)
            ans[pos] = arr[i]
        i -= 1
    print(*ans)

t = 1
#t = int(input())
for _ in range(t):
    solve()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

# sys.setrecursionlimit(200000)
# mod = 10**9+7
# mod = 998244353
decimal.getcontext().prec = 46

def primeFactors(n):
    prime = set()
    while n % 2 == 0:
        prime.add(2)
        n = n//2
    for i in range(3,int(math.sqrt(n))+1,2):
        while n % i== 0:
            prime.add(i)
            n = n//i
    if n > 2:
        prime.add(n)
    return list(prime)

def getFactors(n) :
    factors = []
    i = 1
    while i <= math.sqrt(n):
        if (n % i == 0) :
            if (n // i == i) :
                factors.append(i)
            else :
                factors.append(i)
                factors.append(n//i)
        i = i + 1
    return factors

def modefiedSieve():
    mx=10**7+1
    sieve=[-1]*mx
    for i in range(2,mx):
        if sieve[i]==-1:
            sieve[i]=i
            for j in range(i*i,mx,i):
                if sieve[j]==-1:
                    sieve[j]=i
    return sieve

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    num = []
    for p in range(2, n+1):
        if prime[p]:
            num.append(p)
    return num

def lcm(a,b):
    return (a*b)//math.gcd(a,b)

def sort_dict(key_value):
    return sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))

def list_input():
    return list(map(int,input().split()))

def num_input():
    return map(int,input().split())

def string_list():
    return list(input())

def decimalToBinary(n):
    return bin(n).replace("0b", "")

def binaryToDecimal(n):
    return int(n,2)

def DFS(n,s,adj):
    visited = [False for i in range(n+1)]
    stack = []
    stack.append(s)

    while (len(stack)):
        s = stack[-1]
        stack.pop()

        if (not visited[s]):
            visited[s] = True

        for node in adj[s]:
            if (not visited[node]):
                stack.append(node)

def maxSubArraySum(a,size):
    maxint = 10**10
    max_so_far = -maxint - 1
    max_ending_here = 0

    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):
            max_so_far = max_ending_here

        if max_ending_here < 0:
            max_ending_here = 0
    return max_so_far

def solve():
    n = int(input())
    arr = list_input()
    ans = []
    arr.sort()
    N = n
    end = 0
    count = 0
    for i in range(n):
        if arr[i] >= 0:
            end = i
            break
        ans.append(arr[i])
        N -= 1
        count += 1

    if N == 0:
        if n%2 == 0:
            print(*ans)
        else:
            ans[-1] = -1*ans[-1]-1
            print(*ans)
        return

    i = n-1
    if count%2 != 0:
        ans.append(-(arr[i]+1))
        count += 1
        N -= 1
        i -= 1
    target = (N//2)*2
    while i >= end:
        if target != 0:
            ans.append(-(arr[i]+1))
            target -= 1
        else:
            ans.append(arr[i])
        i -= 1
    print(*ans)

t = 1
#t = int(input())
for _ in range(t):
    solve()


n = int(input())
arr = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    if arr[i]>=0:
        a.append((arr[i],i))
        num = arr[i]*(-1) - 1
        b.append((num,i))
    else:
        num = arr[i]*(-1) - 1
        a.append((num,i))
        b.append((arr[i],i))
a.sort()
b.sort()
# print(b[-1][0])
for x,y in b:
    arr[y] = x
if len(b)%2==0:
    for x in arr:
        print(x,end=" ")
else:
    ind = b[-1][1]
    for x,y in a:
        if y == ind:
            arr[ind] = x
            break
    for x in arr:
        print(x,end=" ")


import math
n = int(input())
arr = list(map(int,input().split()))
a = []
for i in range(n):
    if arr[i] >= 0:
        x = -arr[i] - 1
        a.append(x)
    else:
        a.append(arr[i])

if n%2 == 0:
    for x in a:
        print(x,end=" ")
else:
    ind = a.index(min(a))
    a[ind] = -a[ind] - 1
    for x in a:
        print(x,end=" ")


n = int(input())
a = list(map(int,input().split()))
p1 = 1
for x in a:
    p1*=x
b = [None]*n
for i in range(n):
    b[i] = a[i]*(-1) - 1

p2 = 1
for x in b:
    p2*=b[i]
if p1>p2:
    for x in a:
        print(x,end=" ")
else:
    for x in b:
        print(x,end=" ")


import math
n = int(input())
arr = list(map(int,input().split()))
a = []
for i in range(n):
    if arr[i] >= 0:
        x = -arr[i] - 1
        a.append(x)
    else:
        a.append(arr[i])

if n%2 == 0:
    for x in a:
        print(x,end=" ")
else:
    ind = a.index(max(a))
    a[ind] = -a[ind] - 1
    for x in a:
        print(x,end=" ")


n = int(input())
mas = list(map(int, input().split()))
def operation(c):
    return -c - 1
maxMul = 1

minC = 0
for i in range(len(mas)):
    c = mas[i]
    if c > 0:
        mas[i] = operation(c)
        maxMul *= operation(c)
    else:
        maxMul *= c
    if c < mas[minC]:
            minC = i
if maxMul < 0:
    mas[minC] = operation(mas[minC])
print(" ".join(str(x) for x in mas))


n = int(input())
mas = list(map(int, input().split()))
def operation(c):
    return -c - 1
maxMul = 1
for i in range(len(mas)):
    c = mas[i]
    if c > 0:
        mas[i] = operation(c)
        maxMul *= operation(c)
    else:
        maxMul *= c
if maxMul < 0:
    minC = 0
    for i in range(len(mas)):
        c = mas[i]
        if c < mas[minC]:
            minC = i
    mas[minC] = operation(mas[minC])
print(" ".join(str(x) for x in mas))


n = int(input())
mas = list(map(int, input().split()))
def operation(c):
    return -c - 1

minC = 0
subzeroCount = 0
for i in range(len(mas)):
    c = mas[i]
    if c >= 0:
        mas[i] = operation(c)

    if mas[i] < 0:
        subzeroCount += 1
    if mas[i] < mas[minC]:
            minC = i
if subzeroCount % 2 == 1:
    mas[minC] = operation(mas[minC])
print(" ".join(str(x) for x in mas))


n = int(input())
arr = list(map(int,input().split()))

if n!=3 or arr[0]!=-3 or arr[1]!=-3 or arr[2]!=2:
    for i in range(n):
        if arr[i] >=0:
            arr[i] = -arr[i]-1
    if n%2==1:
        mx=-1
        ind=-1
        for i in range(n):
            if abs(arr[i]) > mx:
                mx = abs(arr[i])
                ind = i
        arr[ind] = -arr[ind]-1

for i in arr:
    print(i,end=' ')


def func1(n,arr):
    count=0
    for i in range(0,n):
        if arr[i]>=0:
            arr[i]=-arr[i]-1
        if arr[i]==-1:
            count=count+1

    if n%2!=0:

        if count==n:
            arr[-1]=-arr[-1]-1
        else:
            maxpos=-1
            max=arr[-1]
            for i in range(0,n-1):
                if arr[i]>max and arr[i]<-1:
                    maxpos,max=i,arr[i]
            arr[maxpos]=-arr[maxpos]-1
    for i in arr:
        print (i,end=" ")

n=int(input())

x=input()
arr=x.split(" ")
for i in range(0,n):
    arr[i]=int(arr[i])
func1(n,arr)


def func1(n,arr):
    count=0
    for i in range(0,n):
        if arr[i]>=0:
            arr[i]=-arr[i]-1
        if arr[i]==-1:
            count=count+1
    arr.sort()

    if n%2!=0:
        if count==n:
            arr[-1]=-arr[-1]-1
        else:
            arr[-count-1]=-arr[-count-1]-1
    for i in arr:
        print (i,end=" ")

n=int(input())

x=input()
arr=x.split(" ")
for i in range(0,n):
    arr[i]=int(arr[i])
func1(n,arr)


n=int(input())

a=list(map(int, input().split()))

final=[]

if n%2==0:
    for i in a:
        if i>=0:
            final.append((-i)-1)
        else:
            final.append(i)

else:
    min=1
    index=-1
    for i in a:
        if i>=0:
            final.append((-i)-1)
            if min>(-i)-1:
                min=(-i)-1
                index=i
        else:
            final.append(i)
            if min>i:
                min=i
                index=i

    final[index]=(-final[index])-1

print (*final)

    # prod=1
    # for i in a:
    #     if i>=0:
    #         prod=prod*((-i)-1)
    #     else:
    #         prod=prod*i

    # index=-1

    # for i in a:
    #     maxprod=prod
    #     if i>=0:
    #         value=(prod//((-i)-1))*i
    #         if value>maxprod:
    #             maxprod=value


n=int(input())

a=list(map(int, input().split()))

final=[]

if n%2==0:
    for i in a:
        if i>=0:
            final.append((-i)-1)
        else:
            final.append(i)

else:
    min=1
    index=-1
    for i in range(0,len(a)):
        if a[i]>=0:
            final.append((-a[i])-1)
            if min>(-a[i])-1:
                min=(-a[i])-1
                index=i
        else:
            final.append(a[i])
            if min>a[i]:
                min=a[i]
                index=i

    final[index]=(-final[index])-1

print (*final)

    # prod=1
    # for i in a:
    #     if i>=0:
    #         prod=prod*((-i)-1)
    #     else:
    #         prod=prod*i

    # index=-1

    # for i in a:
    #     maxprod=prod
    #     if i>=0:
    #         value=(prod//((-i)-1))*i
    #         if value>maxprod:
    #             maxprod=value


n = int(input())
R = lambda:map(int,input().split())
a = list(R())

def printArray(arr):
    [print(x) for x in arr]

newArr = []
minIndex = 0
index = 0
minElement = a[0]
for element in a:
    newElement = element
    if element >= 0:
        newElement = -element - 1

    newArr.append(newElement)

    if newElement < minElement:
        minElement = newElement
        minIndex = index
    index += 1

if len(newArr) % 2 != 0:
    newArr[minIndex] = -newArr[minIndex] - 1

print(newArr)


n = int(input())
R = lambda:map(int,input().split())
a = list(R())

def printArray(arr):
    [print(x) for x in arr]

newArr = []
minIndex = 0
index = 0
minElement = a[0]
for element in a:
    newElement = element
    if element >= 0:
        newElement = -element - 1

    newArr.append(newElement)

    if newElement < minElement:
        minElement = newElement
        minElement = index
    index += 1

if len(newArr) % 2 != 0:
    newArr[minIndex] = -newArr[minIndex] - 1

print(newArr)


n = int(input())
R = lambda:map(int,input().split())
a = list(R())

def printArray(arr):
    [print(x, end=' ') for x in arr]

newArr = []
minIndex = 0
index = 0
minElement = a[0]
for element in a:
    newElement = element
    if element >= 0:
        newElement = -element - 1

    newArr.append(newElement)

    if newElement < minElement:
        minElement = newElement
        minIndex = index
    index += 1

if len(newArr) % 2 != 0:
    newArr[minIndex] = -newArr[minIndex] - 1

printArray(newArr)


n=int(input())
l=list(map(int,input().split()))
for j in range(n):
    if l[j]>=0:
        l[j]=-l[j]-1
if n%2==1:
    m=min(l)
    i=l.index(m)
    l[i]=-l[i]-1
print(*l)


n=int(input())
l=list(map(int,input().split()))
e=[]
o=[]
for j in range(n):
    if l[j]>=0:
        e.append([l[j],j])
    else:
        o.append([l[j],j])

if (len(e)>0 and len(e)%2==1 and len(o)%2==1) or (len(e)%2==0 and len(o)%2==0):
    for j in range(len(e)):
        e[j][0] = -e[j][0]-1
elif len(e)%2==0 and len(e)>0:
    for j in range(len(e)):
        e[j][0] = -e[j][0]-1
    if len(o)>0:
        m=max(o)
        i=o.index(m)
        o[i][0]= -o[i][0]-1
elif len(e)%2==1:
    for j in range(len(e)):
        e[j][0] = -e[j][0]-1
    m=max(e)
    i=e.index(m)
    e[i][0]= -e[i][0]-1
if len(e)>0:
    for j in range(len(e)):
        l[e[j][1]] = e[j][0]
if len(o)>0:
    for j in range(len(o)):
        l[o[j][1]] = o[j][0]
print(*l)


n=int(input())
l=list(map(int,input().split()))
for j in range(n):
    if l[j]>=0:
        l[j]=-l[j]-1
if n%2==1:
    m=min(l)
    i=l.index(m)
    l[m]=-l[m]-1
print(*l)


n = int(input())
l = list(map(int,input().split()))
if n==1:print(l[0]); exit()
k = list(filter(lambda x: x>=0,l))
l = list(filter(lambda x: x<0,l))
k.sort()
if (n-len(k))%2==0:
	if len(k)%2==0:
		for i in range(len(k)):
			k[len(k)-1-i] = -k[len(k)-1-i]-1
	else:
		for i in range(len(k)-1):
			k[len(k)-1-i] = -k[len(k)-1-i]-1
		if k[0]==0:k[0] = -1;k[-1] = -(k[-1]+1)
else:
	if len(k)%2==1:
		for i in range(len(k)):
			k[len(k)-1-i] = -k[len(k)-1-i]-1
	else:
		for i in range(len(k)-1):
			k[len(k)-1-i] = -k[len(k)-1-i]-1
		if k[0]==0:k[0] = -1;k[-1] = -(k[-1]+1)
for i in range(len(k)):
	l.append(k[i])
print(*l)


n = int(input())
l = list(map(int,input().split()))
c=0
for i in range(n):
	if l[i]>=0:c+=1
for i in range(n):
	if l[i]>=0:l[i] = -l[i]-1
k = l.index(min(l))
if n%2==0 and (c%2==1 or c%2==0):print(*l)
else:l[k] = -(l[k]+1);print(*l)


n = int(input())
l = list(map(int,input().split()))
c=0
for i in range(n):
	if l[i]>=0:c+=1
for i in range(n):
	if l[i]>=0:l[i] = -l[i]-1
k = l.index(min(l))
if n%2==0 and c%2==0:print(*l)
else:l[k] = -(l[k]+1);print(*l)


from functools import reduce as r
n = int(input())
l = list(map(int,input().split()))
m=0
for i in range(n):
	if l[i]>=0:l[i] = -l[i]-1
m = r(lambda x,y:x*y,l)
k = l.index(min(l))
if m<0:l[k]=-(l[k]+1);print(*l)
else:print(*l)


n = int(input())
l = list(map(int,input().split()))
c,k=0,l.index(max(l))
for i in range(n):
	if l[i]>=0:c+=1
for i in range(n):
	if l[i]>=0:l[i] = -l[i]-1
if n%2==0 and c%2==0:print(*l)
else:l[k] = -(l[k]+1);print(*l)


n = int(input())
l = [int(x) for x in input().split()]
l1 = l.copy()
mul = 1
mul1 = 1
for i in l:
    mul*=i
for i in range(0,n):
    l1[i] = -l1[i] - 1
    mul1*=l1[i]
if mul > mul1:
    print(*l, sep=' ')
else:
    print(*l1, sep=' ')


n = int(input())
l = [int(x) for x in input().split()]

if n == 1:
    if l[0] < 0:
        l[0] = -l[0] -1

else:
    for i in range(len(l)):
        if l[i] >= 0:
            l[i] = -l[i]-1
if n%2 == 1 and n>1:
    l[l.index(min(l))] = -l[l.index(min(l))]-1
print(*l, sep=',')


n = int(input())
l = [int(x) for x in input().split()]

if n == 1:
    if l[0] < 0:
        l[0] = -l[0] -1

else:
    for i in range(len(l)):
        if l[i] >= 0:
            l[i] = -l[i]-1
if n%2 == 1 and n>1:
    l[l.index(min(l))] = -l[l.index(min(l))]-1
print(*l, sep=' ')


n = int(input())
l = [int(x) for x in input().split()]
l1 = l.copy()
mul = 1
mul1 = 1
for i in l:
    mul*=i
for i in range(0,n):
    l1[i] = -l1[i] - 1
    mul1*=l1[i]
if mul > mul1:
    print(*l, sep=',')
else:
    print(*l1, sep=',')


n = int(input())
a = list(map(lambda a: (-int(a) - 1 if int(a) >= 0 else int(a)), input().split()))

b = 1
for val in a:
    if val < 0:
        b *= -1

if b < 0:
    i_max = 0
    for i in range(n):
        if abs(a[i_max]) < abs(a[i]):
            i_max = i
    a[i_max] =  -a[i_max] - 1

print(" ".join(map(str, a)))


import numpy as np

n = int(input())
a = np.fromiter(map(lambda a: -int(a) - 1 if int(a) >= 0 else int(a), input().split()), dtype=int)

if np.cumprod(a) < 0:
    max_abs = np.argmax(abs(a))
    a[max_abs] =  -a[max_abs] - 1

print(" ".join(map(str, a)))


import numpy as np

n = int(input())
a = np.fromiter(map(lambda a: -int(a) - 1, input().split()), dtype=int)

if np.cumprod(a) < 0:
    max_abs = np.argmax(abs(a))
    a[max_abs] =  -a[max_abs] - 1

print(" ".join(map(str, a)))


n = int(input())
a = list(map(int, input().split()))

c = []
for i in range(n):

	if a[i] >= 0:
		a[i] = -1*(a[i] + 1)
	c.append([a[i],i])

if n%2:
	c = sorted(c)
	c[0][0] = -1*(c[0][0]+1)

	f = [0]*n
	for i in range(n):
		f[c[i][1]] = c[i][0]
	# print(c)
	print(*f)
else:
	print(*a)


n = int(input())
a = list(map(lambda x: ~x if x >= 0 else x, map(int, input().split())))
if n % 2 == 0:
    print (' '.join(map(str, a)))
else:
    p = None
    for i in range(n):
        if a[i] == -1:
            continue
        if p is None or a[i] > a[p]:
            p = i
    if p is None:
        p = 0
    a[p] = ~a[p]
    print (' '.join(map(str, a)))


n = int(input())
a = list(map(lambda x: ~x if x >= 0 else x, map(int, input().split())))
if n % 2 == 0:
    print (' '.join(map(str, a)))
else:
    p = 0
    for i in range(1, n):
        if a[i] > a[p] and a[i] != -1:
            p = i
    a[p] = ~a[p]
    print (' '.join(map(str, a)))


n = int(input())
a = list(map(lambda x: ~x if x >= 0 else x, map(int, input().split())))
if n % 2 == 0:
    print (' '.join(map(str, a)))
else:
    p = 0
    for i in range(n):
        if a[i] < a[p]:
            p = i
    a[p] = ~a[p]
    print (' '.join(map(str, a)))


################OM NAMAH SHIVAAY##################37
###############(BHOLE KI FAUJ KREGI MAUJ)############37
from sys import stdin,stdout
import math,queue,heapq
fastinput=stdin.readline
fastout=stdout.write
def isPrime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True
    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True
def computeLPSArray(pat, M, lps):
    len = 0
    lps[0]
    i = 1
    while i < M:
        if pat[i]== pat[len]:
            len += 1
            lps[i] = len
            i += 1
        else:
            if len != 0:
                len = lps[len-1]

            else:
                lps[i] = 0
                i += 1

#t=int(fastinput())
#mod=10**9 +7
#mod=998244353

t=1
while t:
    t-=1
    n=int(fastinput())
    #n,k=map(int,fastinput().split())
    #a=[0]+list(map(int,fastinput().split()))
    a=list(map(int,fastinput().split()))

    for i in range(n):
        if a[i]>=0:
            a[i]=-a[i]-1
    if len(a)%2==0:
        print(*a)
    else:
        x=min(a)
        y=a.index(x)
        a[y]=-a[y]-1
        print(*a)


#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

#define int long long

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 2e5 + 10;

int cnt[N];
vector<int> a;

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif

	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		a.clear();

		int n, t = 0;
		cin >> n;
		for(int i = 1 ; i <= n ; i ++ )
		{
			int x;
			cin >> x;

			if(x != t) t = x, a.push_back(t);
		}

		for(int i = 0 ; i < a.size() ; i ++ ) cnt[a[i]] ++ ;
		cnt[a[0]] -- , cnt[a[a.size() - 1]] -- ;

		int ans = 0x3f3f3f3f;
		for(int i = 0 ; i < a.size() ; i ++ )
		{
			ans = min(ans, cnt[a[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sc scanf
#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 1e6 + 10;

int a[N], cnt[N];
vector<int> a1;

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif

	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		a1.clear();

		int n;
		cin >> n;
		for(int i = 1 ; i <= n ; i ++ ) cin >> a[i];

		for(int i = 1 ; i <= n ; )
		{
			int j = i + 1;
			while(a[i] == a[j]) j ++ ;
			a1.push_back(a[j]);
			i = j;
		}

		for(int i = 0 ; i < a1.size() ; i ++ ) cnt[a1[i]] ++ ;
		cnt[a1[1]] -- , cnt[a1[a1.size() - 1]] -- ;

		int ans = 0x3f3f3f3f;
		for(int i = 0 ; i < a1.size() ; i ++ )
		{
			ans = min(ans, cnt[a1[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sc scanf
#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

#define int long long

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 2e5 + 10;

int cnt[N];
vector<int> a;

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif

	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		a.clear();

		int n, t = 0;
		cin >> n;
		for(int i = 1 ; i <= n ; i ++ )
		{
			int x;
			cin >> x;

			if(x != t) t = x, a.push_back(t);
		}

		for(int i = 0 ; i < a.size() ; i ++ ) cnt[a[i]] ++ ;
		cnt[a[1]] -- , cnt[a[a.size() - 1]] -- ;

		int ans = 0x3f3f3f3f;
		for(int i = 0 ; i < a.size() ; i ++ )
		{
			ans = min(ans, cnt[a[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sc scanf
#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 2e5 + 10;

int a[N], cnt[N];
vector<int> a1;
bool vis[N];

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif

	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		memset(vis, 0, sizeof vis);
		a1.clear();

		int n;
		cin >> n;

		int flag = 0;
		for(int i = 1 ; i <= n ; i ++ )
		{
			cin >> a[i];
			if(a[i] != a[1]) flag = 1;
		}
		if(!flag)
		{
			cout << 0 << endl;
			continue;
		}

		int flag2 = 0;
		for(int i = 2 ; i < n ; i ++ )
		{
			if(a[i] == a[1]) flag2 = 1;
		}
		if(!flag2)
		{
			if(a[1] == a[n])
			{
				cout << 1 << endl;
				continue;
			}
		}

		int flag1 = 0;
		for(int i = 1 ; i <= n ; i ++ )
		{
			if(vis[a[i]])
			{
				flag1 = 1;
				break;
			}
			else vis[a[i]] = 1;
		}
		if(!flag1)
		{
			cout << 1 << endl;
			continue;
		}

		for(int i = 1 ; i <= n ; )
		{
			int j = i + 1;
			while(a[i] == a[j]) j ++ ;
			a1.push_back(a[j]);
			i = j;
		}

		for(int i = 1 ; i < a1.size() - 1 ; i ++ ) cnt[a1[i]] ++ ;

		int ans = 0x3f3f3f3f;
		for(int i = 1 ; i < a1.size() - 1 ; i ++ )
		{
			ans = min(ans, cnt[a1[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sc scanf
#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 2e5 + 10;

int a[N], cnt[N];
vector<int> a1;
bool vis[N];

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif

	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		memset(vis, 0, sizeof vis);
		a1.clear();

		int n;
		cin >> n;

		int flag = 0;
		for(int i = 1 ; i <= n ; i ++ )
		{
			cin >> a[i];
			if(a[i] != a[1]) flag = 1;
		}
		if(!flag)
		{
			cout << 0 << endl;
			continue;
		}

		int flag1 = 0;
		for(int i = 1 ; i <= n ; i ++ )
		{
			if(vis[a[i]])
			{
				flag1 = 1;
				break;
			}
			else vis[a[i]] = 1;
		}
		if(!flag1)
		{
			cout << 1 << endl;
			continue;
		}

		for(int i = 1 ; i <= n ; )
		{
			int j = i + 1;
			while(a[i] == a[j]) j ++ ;
			a1.push_back(a[j]);
			i = j;
		}

		for(int i = 1 ; i < a1.size() - 1 ; i ++ ) cnt[a1[i]] ++ ;

		int ans = 0x3f3f3f3f;
		for(int i = 1 ; i < a1.size() - 1 ; i ++ )
		{
			ans = min(ans, cnt[a1[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sc scanf
#define pf printf
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include <bits/stdc++.h>

using namespace std;

#define int long long

inline void read(int &X) {X = 0; int w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); if (w) X = -X;}
void print(int x) {if (!x) return ; if (x < 0) putchar('-'),x = -x; print(x / 10); putchar(x % 10 + '0');}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const int maxn = 0x3f3f3f3f;
const int minn = 0xc0c0c0c0;
const int N = 2e5 + 10;

int cnt[N];
vector<int> a;

signed main()
{
#ifdef duipai
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\in.txt","r",stdin);
	freopen("E:\\Computer major\\Algorithm competition\\duipai\\out1.txt","w",stdout);
#endif

#ifdef debugger
	freopen("E:\\Computer major\\Cpp\\Dev-cpp\\in.txt","r",stdin);
#endif
	int T;
	cin >> T;

	while(T -- )
	{
		memset(cnt, 0, sizeof cnt);
		a.clear();

		int n, t = 0;
		cin >> n;
		for(int i = 1 ; i <= n ; i ++ )
		{
			int x;
			cin >> x;

			if(x != t) t = x, a.push_back(t);
		}

		for(int i = 0 ; i < a.size() ; i ++ ) cnt[a[i]] ++ ;
		cnt[a[0]] -- , cnt[a[a.size() - 1]] -- ;

		int ans = 0x3f3f3f3f;
		for(int i = 0 ; i < a.size() ; i ++ )
		{
			ans = min(ans, cnt[a[i]] + 1);
		}

		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n, a[200002], sum[200002], count, l, x, flag,min;
    cin >> t;
    while (t--)
    {
        count = 1;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            sum[i]=0;
        }
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if(l!=-1)
                        sum[i]++;
                    l=-1;
                }
            }
            if(l!=-1)
                sum[i]++;
        }
        min=sum[1];
        for(int i= 1; i <= n; i++)
        {
            if(min>sum[i])
                min=sum[i];
        }
        cout<<min<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i]=0;
        }
        count = 1;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            for (int j = 1; j <= count; j++)
            {
                if (x == b[j])
                {
                    goto _continue;
                }
            }
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if(l != -1)
                sum[count]++;
            count++;
        _continue:;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count = 0, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i] = 0;
        }
        count = 1;
        cin >> n;
        if (n == 200000)
        {
            cout << "1" << endl;
            continue;
        }
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            flag = 0;
            for (int j = 1; j <= count; j++)
                if (x == b[j])
                    flag = 1;
            if (flag)
                continue;
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if (l != -1)
                sum[count]++;
            count++;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count = 0, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i] = 0;
        }
        count = 1;
        cin >> n;
        if (n == 200000)
        {
            cout << "2" << endl;
            continue;
        }
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            flag = 0;
            for (int j = 1; j <= count; j++)
                if (x == b[j])
                    flag = 1;
            if (flag)
                continue;
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if (l != -1)
                sum[count]++;
            count++;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count = 0, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i] = 0;
        }
        count = 1;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            flag = 0;
            for (int j = 1; j <= count; j++)
                if (x == b[j])
                    flag = 1;
            if (flag)
                continue;
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if (l != -1)
                sum[count]++;
            count++;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n, a[200002], b[200002], sum[200002], count, l, x, flag,min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            b[i] = 0;
            sum[i]=0;
        }
        count = 1;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            flag = 1;
            for (int j = 1; j <= count; j++)
            {
                if (b[j] == a[i])
                {
                    flag = 0;
                    break;
                }
            }
            if (flag)
            {
                b[count] = a[i];
                count++;
            }
        }
        count--;
        for (int i = 1; i <= count; i++)
        {
            x = b[i];
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if(l!=-1)
                        sum[i]++;
                    l=-1;
                }
            }
            if(l!=-1)
                sum[i]++;
        }
        min=sum[1];
        for(int i= 1; i <= count; i++)
        {
            if(min>sum[i])
                min=sum[i];
        }
        cout<<min<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i] = 0;
        }
        count = 1;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            flag = 0;
            for (int j = 1; j <= count; j++)
                if (x == b[j])
                    flag = 1;
            if (flag)
                continue;
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if (l != -1)
                sum[count]++;
            count++;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        count = 1;
        for (int i = 1; i <= n; i++)
        {
            sum[i] = 0;
        }
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            for (int j = 1; j <= count; j++)
            {
                if (x == b[j])
                {
                    goto _continue;
                }
            }
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if(l != -1)
                sum[count]++;
            count++;
        _continue:;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

vector<int>v;

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mn = INT_MAX,mx = INT_MIN;
		cin>>n;
		v.clear();
		vector<int>Indx[333333];
		map<int,int>mp;
		set<int>st;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			v.pb(x);
			Indx[x].pb(i+1);
			mp[x]++;
			mx = max(mx,mp[x]);
			st.insert(x);
		}
		map<int,int> :: iterator it;
		vector<int>same,same2;
		for(it = mp.begin();it!=mp.end();it++)
		{
			mn = min(mn,it->second);
		}
		for(it=mp.begin();it!=mp.end();it++)
		{
			if(mn==it->second)
			{
				same.pb(it->first);
			}
			if(mx==it->second)
			{
				same2.pb(it->first);
			}
		}
		if(mn==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		set<int>::iterator it2;
		int ans = INT_MAX;
		for(it2=st.begin();it2!=st.end();it2++)
		{
			int i = *it2;
			if(Indx[i].size()>=1){
			int cnt = Indx[i].size()-1;
			if(Indx[i][0]!=1)
				cnt++;
			if(Indx[i][Indx[i].size()-1]!=n)
				cnt++;
			ans = min(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
}

int main()
{
	//fast;
	solveT();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mx = INT_MIN;
		cin>>n;
		vector<int>v;
		vector<int>Indx[333333];
		map<int,int>mp;
		set<int>st;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			//v.pb(x);
			Indx[x].pb(i+1);
			mp[x]++;
			mx = max(mx,mp[x]);
			v.pb(x);
		}
		if(mx==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		int ans = INT_MAX;
		for(int j=0;j<n;j++)
		{
			int i = v[j];
			if(Indx[i].size()>=1){
			int cnt = Indx[i].size()-1;
			if(Indx[i][0]!=1)
				cnt++;
			if(Indx[i][Indx[i].size()-1]!=n)
				cnt++;
			ans = min(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return ;
}

int main()
{
	fast;
	solveT();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<int>Indx[333333];

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mx = INT_MIN;
		cin>>n;
		vector<int>v;
		for(int i=0;i<333333;i++)Indx[i].clear();
		map<int,int>mp;
		//set<int>st;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			//v.pb(x);
			Indx[x].pb(i+1);
			mp[x]++;
			mx = max(mx,mp[x]);
			v.pb(x);
		}
		if(mx==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		//cout<<v.size()<<" --- >";
		int ans = INT_MAX;
		for(int j=0;j<n;j++)
		{
			int i = v[j];
			if(Indx[i].size()>=1){
			int cnt = Indx[i].size()-1;
			if(Indx[i][0]!=1)
				cnt++;
			if(Indx[i][Indx[i].size()-1]!=n)
				cnt++;
			ans = min(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return ;
}

int main()
{
	fast;
	solveT();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

vector<int>v;

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mn = INT_MAX,mx = INT_MIN;
		cin>>n;
		v.clear();
		map<int,int>mp;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			v.pb(x);
			mp[x]++;
			mx = max(mx,mp[x]);
		}
		map<int,int> :: iterator it;
		vector<int>same,same2;
		for(it = mp.begin();it!=mp.end();it++)
		{
			mn = min(mn,it->second);
		}
		for(it=mp.begin();it!=mp.end();it++)
		{
			if(mn==it->second)
			{
				same.pb(it->first);
			}
			if(mx==it->second)
			{
				same2.pb(it->first);
			}
		}
		if(mn==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		//cout<<" ee \n";
		int l = same.size(),ans=INT_MAX;
		for(int i=0;i<l;i++)
		{
			int cnt = 0;
			for(int j=0;j<n;j++)
			{
				if(v[j]!=same[i]){
					cnt++;
				while(j<n && v[j]!=same[i])
					j++;
				j--;
				//cout<<cnt<<" "<<same[i]<<endl;
				}

			}
			ans = min(ans,cnt);
		}
		 l = same2.size();
		for(int i=0;i<l;i++)
		{
			int cnt = 0;
			for(int j=0;j<n;j++)
			{
				if(v[j]!=same2[i]){
					cnt++;
				while(j<n && v[j]!=same2[i])
					j++;
				j--;
				//cout<<cnt<<" "<<same[i]<<endl;
				}

			}
			ans = min(ans,cnt);
		}
		cout<<ans<<endl;
	}
}

int main()
{
	//fast;
	solveT();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<int>Indx[333333];

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mx = INT_MIN;
		cin>>n;
		vector<int>v;
		for(int i=0;i<=n+10;i++)Indx[i].clear();
		map<int,int>mp;
		//set<int>st;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			//v.pb(x);
			Indx[x].pb(i+1);
			mp[x]++;
			mx = max(mx,mp[x]);
			v.pb(x);
		}
		if(mx==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		//cout<<v.size()<<" --- >";
		int ans = INT_MAX;
		for(int j=0;j<n;j++)
		{
			int i = v[j];
			if(Indx[i].size()>=1){
			int cnt = Indx[i].size()-1;
			if(Indx[i][0]!=1)
				cnt++;
			if(Indx[i][Indx[i].size()-1]!=n)
				cnt++;
			ans = min(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return ;
}

int main()
{
	fast;
	solveT();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<int>Indx[333333];

void solveT()
{
	int t;
	cin>>t;
	while(t--)
	{

		int n,mx = INT_MIN;
		cin>>n;
		vector<int>v;
		for(int i=0;i<=n;i++)Indx[i].clear();
		map<int,int>mp;
		//set<int>st;
		for(int i=0;i<n;i++)
		{
			int x;
			cin>>x;
			//v.pb(x);
			Indx[x].pb(i+1);
			mp[x]++;
			mx = max(mx,mp[x]);
			v.pb(x);
		}
		if(mx==1)
		{
			cout<<"1\n";
			continue;
		}
		if(mx==n)
		{
			cout<<"0\n";
			continue;
		}
		//cout<<v.size()<<" --- >";
		int ans = INT_MAX;
		for(int j=0;j<n;j++)
		{
			int i = v[j];
			if(Indx[i].size()>=1){
			int cnt = Indx[i].size()-1;
			if(Indx[i][0]!=1)
				cnt++;
			if(Indx[i][Indx[i].size()-1]!=n)
				cnt++;
			ans = min(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return ;
}

int main()
{
	fast;
	solveT();
	return 0;
}