Nick had received an awesome array of integers a=[a1,a2,…,an]a=[a1,a2,…,an] as a gift for his 55 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⋅…ana1⋅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 ii (1≤i≤n1≤i≤n) and do ai:=−ai−1ai:=−ai−1.
For example, he can change array [3,−1,−4,1][3,−1,−4,1] to an array [−4,−1,3,1][−4,−1,3,1] after applying this operation to elements with indices i=1i=1 and i=3i=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⋅…ana1⋅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 nn (1≤n≤1051≤n≤105) — number of integers in the array.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (−106≤ai≤106−106≤ai≤106) — elements of the array
Output
Print nn 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.
Examples
Input
4
2 2 2 2
Output
-3 -3 -3 -3
Input
1
0
Output
0
Input
3
-3 -3 2
Output
-3 -3 2
题面:找序列题目里面的有几个然后删掉以后可以满足条件
注意判断条件
#include<iostream>
#include<map>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
#pragma warning (disable:4786)
const int maxn=1e5+10;
int main()
{
int n;
scanf("%d",&n);
vector<int>a(n);
for(int i=0;i<n;i++)
{
int v;
scanf("%d",&v);
if(v==4)a[i]=1;
if(v==8)a[i]=2;
if(v==15)a[i]=3;
if(v==16)a[i]=4;
if(v==23)a[i]=5;
if(v==42)a[i]=6;
}
vector<int>cur(7);
cur[0]=n;
for(int i=0;i<n;i++)
{
if(cur[a[i]-1]>0)
{
++cur[a[i]];
--cur[a[i]-1];
}
}
int ans=n-6*cur[6];
printf("%d",ans);
}