Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a1, a2, ..., an. His teapot stores w milliliters of tea (w ≤ a1 + a2 + ... + an). Polycarp wants to pour tea in cups in such a way that:  Every cup will contain tea for at least half of its volume  Every cup will contain integer number of milliliters of tea  All the tea from the teapot will be poured into cups  All friends will be satisfied. Friend with cup i won't be satisfied, if there exists such cup j that cup i contains less tea than cup j but ai > aj.For each cup output how many milliliters of tea should be poured in it. If it's impossible to pour all the tea and satisfy all conditions then output -1.

The first line contains two integer numbers n and w (1 ≤ n ≤ 100, ). The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 100).

Output how many milliliters of tea every cup should contain. If there are multiple answers, print any of them. If it's impossible to pour all the tea and satisfy all conditions then output -1.

NoteIn the third example you should pour to the first cup at least 5 milliliters, to the second one at least 4, to the third one at least 5. It sums up to 14, which is greater than 10 milliliters available.

#include <bits/stdc++.h>
using namespace std;
struct node{
	int x,id;
	friend bool operator <(node a,node b){
		return a.x>b.x;
	}
} a[105];
int n,w,ans[105];
int main(){
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		a[i].x=x;
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		ans[a[i].id]=(a[i].x+1)/2;
		w-=ans[a[i].id];
	}
	if(w<0)	return puts("-1"),0;
	int cur=1;
	while(w>0){
//		cout<<"w="<<w<<endl;
//		cout<<a[cur].x-ans[a[cur].id]<<endl;
		if(a[cur].x-ans[a[cur].id]>=w){
			ans[a[cur].id]+=w;
			break;
		}
		else{
			w-=a[cur].x-ans[a[cur].id];
			ans[a[cur].id]=a[cur].x;
		}
		cur++;
	}
	for(int i=1;i<=n;i++)	cout<<ans[i]<<" ";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gc getchar_unlocked
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x) cout<<\t \t <<x<<endl
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pll pair<ll,ll>
#define fo(i,n) for(i=0;i<n;i++)
#define foa(i,s,e) for(i = s;i<e;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
const int mod = 1000000007;

void solve(){
    //make sure that "cin>>t;" in the main function is compatible with number of test cases.
    ll n,w,i=0,j=0,k=0,sum=0,sum2=0;
    cin>>n>>w;
    vpl v,v2;
    ll ans[n];
    fo(i,n){
        cin>>j;
        v.pb(mp(j,i));
        sum2+=j;
        if(j%2) j++;
        sum+=j;
    }
    sort(all(v));
    if(sum/2 >w || sum2<w) cout<<-1;
    else{
        fo(i,n){
            ll tmp=(v[i].F);
            if(tmp%2) tmp++;
            v2.pb(mp(tmp/2,v[i].S));
        }

        ll rem=w-sum/2;
        for(i=n-1;i>=0;i--){
            ll mn=min((v[i].F)/2, rem);
            (v2[i].F)+=mn;
            rem-=mn;
            if(rem<=0) break;
        }
        fo(i,n){
            ans[v[i].S]=v2[i].F;
        }

        fo(i,n) cout<<ans[i]<<" ";
    }

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t=1;
    // cin>>t;

    while(t--){
        solve();
    }

	return 0;
}

#include <bits/stdc++.h>

#define MAXN (110)

int n, w;
std::pair<int, int> a[MAXN];
int ans[MAXN];

int main(){
	scanf("%d%d", &n, &w);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	std::sort(a + 1, n + a + 1);
	for(int i = 1; i <= n; ++ i){
		ans[a[i].second] = (a[i].first + 1) / 2;
		w -= ans[a[i].second];
	}
	if(w < 0) return printf("-1\n"), 0;
	for(int i = n; i >= 1 && w; -- i){
		int tmp = std::min(a[i].first - ans[a[i].second], w);
		ans[a[i].second] += tmp;
		w -= tmp;
	}
	if(w) return printf("-1\n"), 0;
	for(int i = 1; i <= n; ++ i){
		printf("%d%c", ans[i], " \n"[i == n]);
	}
	return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const int N = (int) 1e6 + 5;
const int mod = (int) 1e9 + 7;

int n,w,sum;
int a[N],res[N];

vector<pair<int,int> > v;

int main () {
	ios_base::sync_with_stdio(false);

        cin >> n >> w;

        for (int i = 1; i <= n; i ++) {
                cin >> a[i];
                v.pb({a[i],i});
                sum += (int)((a[i] + (a[i] % 2)) / 2);
        }

        sort(v.begin(),v.end());

        if (sum > w) {
                puts("-1");
                return 0;
        }

        for (int i = 0; i < v.size(); i ++) {
                res[v[i].sc] = (v[i].fr + (v[i].fr % 2)) / 2;
                w -= (int)((v[i].fr + (v[i].fr % 2)) / 2);
        }

        for (int i = v.size() - 1; i >= 0; i --) {
                if (w == 0)
                        break;
                if (w + res[v[i].sc] >= a[v[i].sc] )
                        w -= a[v[i].sc] - res[v[i].sc],res[v[i].sc] = a[v[i].sc];
                else
                        res[v[i].sc] += w,w = 0;

        }

        for (int i = 1; i <= n; i ++)
                cout << res[i] << " ";
        return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,w,ww,x,y;
struct lyf{
    int num, pos,ans;
}a[105];
bool cmp1(lyf a, lyf b) {return a.num > b.num;}
bool cmp2(lyf a, lyf b) {return a.pos < b.pos;}
int main()
{
    scanf("%d%d",&n,&w);
    ww=w;
    for(int i = 1; i <= n; i++)
	{
        scanf("%d", &a[i].num);
        a[i].pos=i;
        a[i].ans=a[i].num/2;
        if(a[i].num&1) a[i].ans++;
        x+=a[i].num;
        y+=a[i].ans;
        w-=a[i].ans;
    }
    if(ww>x || ww<y) printf("-1\n");
    else
    {
        sort(a+1,a+1+n,cmp1);
        for(int i = 1; i <= n; i++){
            if(w + a[i].ans >= a[i].num){
                w-=a[i].num-a[i].ans;
				a[i].ans=a[i].num;
            }
            else{a[i].ans+=w;w=0;}
            if(!w) break;
        }
        sort(a+1, a+1+n, cmp2);
        for(int i = 1; i <= n; i++)
            printf("%d%c", a[i].ans,i<n? ' ':'\n');
    }
}

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n,w;
    scanf("%d%d", &n, &w);
    vector<pair<int,int> > z;   //val,id
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        z.push_back(make_pair(tmp,i));
    }
    sort(z.begin(), z.end());

    vector<ll> ans0(n),ans1(n);
    ll sum[2]={0,0};
    for(i=0; i<n; i++) {
        ans0[i]=(z[i].first+1)/2;
        sum[0]+=ans0[i];
        ans1[i]=(z[i].first);
        sum[1]+=ans1[i];
    }
    if(sum[0]>w || sum[1]<w) {
        printf("-1\n"); return 0;
    }
    ll diff=w-sum[0];
    for(i=n-1; i>=0; i--) {
        if(diff>0 && diff<=ans1[i]-ans0[i]) {
            ans0[i]+=diff;
            diff=0;
        }
        else if(diff>0 && diff>ans1[i]-ans0[i]) {
            diff-=(ans1[i]-ans0[i]);
            ans0[i]=ans1[i];
        }
    }

    vector<ll> ans(n);
    for(i=0; i<n; i++) {
        ans[z[i].second]=ans0[i];
    }
    for(i=0; i<n; i++) {
        printf("%lld", ans[i]);
        if(i<n-1) printf(" ");
    }
    printf("\n");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define TR(...)
#endif
const int MOD = 1000000007;
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define SZ(a) (int)(a.size())
#define MP make_pair
typedef long long int 	LL;
const int N = 111;
pair<int, int > a[N];
int g[N];

int main() {
    int n, w;
    cin>>n>>w;
    for(int i = 1;i <= n; ++i) cin>>a[i].F, a[i].S = i;
    sort(a + 1, a + n + 1);
    a[0].F = -111;
    int add = 0;
    for(int i = 1;i <= n; ++i) {
        int id = a[i].S;
        int half = 0;
        //if(a[i-1].F != a[i].F) add++;
        half = (a[i].F + 1)/2;
        if(add < half) add = half;
        g[id] = add;
        w -= g[id];
    }
    if(w < 0) return 0*printf("-1\n");
    int ind = n;
    while(w) {
        if(g[a[ind].S] < a[ind].F)
            g[a[ind].S]++, w--;
        else {
            ind = n;
            continue;
        }
        ind--;
        if(ind == 0) ind = n;
    }
    for(int i = 1;i <= n; ++i)
        printf("%d ",g[i]);
    printf("\n");
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 105;
typedef struct MYTEA
{
    int tea;
    int teas;
    int num;
} mytea;
mytea math[MAXN];
bool cmp(const mytea &a,const mytea &b)
{
    return a.tea>b.tea;
}
bool cmps(const mytea &a,const mytea &b)
{
    return a.num<b.num;
}
int main()
{
    int n,w;
    while(~scanf("%d%d",&n,&w))
    {
        for(int i=0; i<n; i++)
        {
            int ans;
            scanf("%d",&ans);
            if(ans%2==0)
            {
                math[i].num=i;
                math[i].tea=ans;
                math[i].teas=ans/2;
            }
            else
            {
                math[i].num=i;
                math[i].tea=ans;
                math[i].teas=ans/2+1;
            }
        }
        sort(math,math+n,cmp);
//        for(int i=0;i<n;i++)
//        {
//            printf("%d %d %d\n",math[i].num,math[i].tea,math[i].teas);
//        }
        bool flag=false;
        for(int i=0; i<n; i++)
        {
            if(w>=math[i].teas)
            {
                w=w-math[i].teas;
            }
            else
            {
                flag=true;
                break;
            }
        }
        if(w>0)
        {
            for(int i=0; i<n; i++)
            {
                if(w>=(math[i].tea-math[i].teas))
                {
                    w=w-math[i].tea+math[i].teas;
                    math[i].teas=math[i].tea;
                }
                else
                {
                    math[i].teas=math[i].teas+w;
                    w=0;
                    break;
                }
            }
            if(w>0)
            {
                flag=true;
                break;
            }
        }
        if(flag)
            printf("-1\n");
        else
        {
            sort(math,math+n,cmps);
            for(int i=0;i<n;i++)
                printf("%d ",math[i].teas);
            puts("");
        }

        }
    return 0;
}
/*2018-07-21 21:08:34.221*/

#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

struct teacup{
	int cup;
	int wat;
	int num;
}tea[105];

bool cmp1(teacup a,teacup b){
	return a.cup>b.cup;
}

bool cmp2(teacup a,teacup b){
	return a.num<b.num;
}

int main(){
	int n,w;
	int now;
	scanf("%d %d",&n,&w);
	for(int i=0;i<n;i++){
		scanf("%d",&tea[i].cup);
		tea[i].num=i;
	}
	sort(tea,tea+n,cmp1);
	int sum=0;

	for(int i=0;i<n;i++){
		tea[i].wat=tea[i].cup/2+tea[i].cup%2;
		sum+=tea[i].wat;
	}
	if(sum>w){
		printf("-1\n");
		return 0;
	}
	else{

		int left=w-sum;
		for(int i=0;i<n;i++){
			if(left==0){
				break;
			}
			if (i==0){
				if(tea[i].cup-tea[i].wat>=left){
					tea[i].wat+=left;
					left=0;
					break;
				}
				else{
					left=left-(tea[i].cup-tea[i].wat);
					tea[i].wat=tea[i].cup;
				}
			}
			else{
				now=min(tea[i-1].wat-tea[i].wat,tea[i].cup-tea[i].wat);
				if(now>=left){
					tea[i].wat+=left;
					left=0;
					break;
				}
				else{
					left-=now;
					tea[i].wat+=now;
				}
			}
		}
		if(left>0){
			printf("-1\n");
			printf("%d\n",left);

			return 0;
		}
		sort(tea,tea+n,cmp2);
		for(int i=0;i<n;i++){
			printf("%d ",tea[i].wat);
		}
		printf("\n");

	}

	return 0;

}

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int n, w;
    cin >> n >> w;

    vector<int> v(n);
    for (int &e : v)
        cin >> e;

    vector<int> res(n, 0);
    for (int i = 0; i < n; i++) {
        int cnt = v[i] / 2 + v[i] % 2;

        if (w < cnt) {
            cout << -1 << endl;
            return 0;
        }

        res[i] += cnt;
        w -= cnt;
    }

    vector<pair<int, int> > t(n);
    for (int i = 0; i < n; i++) {
        t[i].first = v[i];
        t[i].second = i;
    }
    sort(t.begin(), t.end(), [](pair<int, int>  a, pair<int, int> b) { return (a > b); });

    for (int i = 0; i < n; i++) {
        int cnt = min(t[i].first - res[t[i].second], w);
        res[t[i].second] += cnt;
        w -= cnt;
    }

    if (w != 0) {
        cout << -1 << endl;
        return 0;
    }

    copy(res.begin(), res.end(), ostream_iterator<int>(cout, " "));
}

#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;

int main(){

long long max=0,sum=0,t,n,w,def;
cin>>n>>w;
map<long long,long long>m;
vector<long long>v,v2;
for(int i=0 ;i<n;i++){
	cin>>t;
	if(max<t)
		max=t;
	sum=sum+ceil(t/2.0);
	v.push_back(t);
	m[t]=0;
	v2.push_back(t);
}
max=max-ceil(max/2.0);
def=w-sum;
if(sum>w)
	cout<<-1<<endl;
else{
	sort(v2.begin(),v2.end());
	for(int i=v2.size()-1;i>=0;i--){
		if(def==0)
		break;
	else{
		if(v2[i]-ceil(v2[i]/2.0)<def)
		{	m[v2[i]]=m[v2[i]]+v2[i]-ceil(v2[i]/2.0);
		def=def-(v2[i]-ceil(v2[i]/2.0));
		}else{
			m[v2[i]]+=def;
			def=0;

		}

	}

	}
for(int i=0;i<v.size();i++)
{
	if(m[v[i]]>v[i]-ceil(v[i]/2.0))
	{
	cout<<v[i];
	m[v[i]]=m[v[i]]-(v[i]-ceil(v[i]/2.0));
	}else{
cout<<ceil(v[i]/2.0)+m[v[i]];
m[v[i]]=0;
	}
if(i==v.size()-1)
	cout<<endl;
else cout<<" ";

}
}

//system("pause");
return 0;

}

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int num , Max , res = 0 , m = 0 , Try = 0;
    cin >> num >> Max;
    Try = Max;
    int cup[num],cup1[num],cup2[num];
    for(int i = 0;i < num;i++)
    {
        cin >> cup[i];
        if(cup[i] % 2 == 0){
            res += cup[i] / 2;Try -= cup[i]/2;cup1[i] = cup[i];cup2[i] = cup[i]/2;}
        else
            {res += cup[i]/2 + 1;Try-=cup[i]/2+1;cup1[i] = cup[i];cup2[i]=cup[i]/2+1;}
    }
    if(res > Max)
    {
        cout << "-1" << endl;
        return 0;
    }
    sort(cup1,cup1+num);
    reverse(cup1,cup1+num);
    //cout << Try << endl;
    //if(Try!= 0){
    for(int u = 0;u < num;u++)
    {
        for(int w = 0;w < num;w++)
        {
            if(cup1[u] == cup[w])
            {
               while(Try != 0 && cup2[w] != cup[w])
               {
                   cup2[w]++;
                   Try--;
               }
            }
        }
    }
    //cout << Try << endl;
for(int g = 0;g < num;g++)
    cout << cup2[g] << " ";
    return 0;
}

//g++  5.4.0

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

struct cf808c {
    int capacity;
    int quantity;
    int index;
};

int main()
{
    int n, w;
    cin >> n >> w;
    if (n > w) {
        cout << -1 << endl;
        return 0;
    }
    int temp = w;
    vector<cf808c> v(n);
    for (int i = 0; i < n; i++) {
        v[i].index = i;
        cin >> v[i].capacity;
        v[i].quantity = (v[i].capacity % 2 == 1) ? ((v[i].capacity + 1) / 2) : (v[i].capacity / 2);
        temp -= v[i].quantity;
    }

    if (temp < 0) {
        cout << -1 << endl;
        return 0;
    }

    sort(v.begin(), v.end(), [](const cf808c &a, const cf808c &b) {
        if (a.capacity > b.capacity) {
            return true;
        }
        return false;
    });

    /*
    for (int i = 0; i < n; i++) {
        cout << v[i].capacity << "\t" << v[i].quantity << endl;
    }
    */

    //cout << "******" << endl;

    int index = 0;
    int full = 0;
    while (true) {
        //cout << temp << endl;
        if (temp == 0) {
            break;
        }

        while (v[index].quantity != v[index].capacity && temp != 0) {
            v[index].quantity++;
            temp--;
        }
        if (v[index].quantity == v[index].capacity) {
            full++;
        }

        if (index == n - 1) {
            index = full;
        }
        else {
            index++;
        }
    }

    sort(v.begin(), v.end(), [](const cf808c &a, const cf808c &b) {
        if (a.index < b.index) {
            return true;
        }
        return false;
    });

    for (int i = 0; i < n; i++) {
        cout << v[i].quantity << " "; // << v[i].capacity << " " << v[i].quantity << endl;
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
using namespace std;
const int N = 100100;
struct node
{
    int v;
    int p;
    int ans;

};
int cmp1(const node &a,const node &b)
{
    return a.v<b.v;
}
int cmp2(const node &a,const node &b)
{
    return a.p<b.p;
}

node a[N];
int n,w;
int main()
{

    scanf("%d%d",&n,&w);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i].v);
        a[i].p=i;
    }
    sort(a+1,a+n+1,cmp1);
    for (int i=1;i<=n;++i)
    {
        a[i].ans=ceil(a[i].v*1.0/2);
    }

    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<i;++j)
        {
            if (a[i].v>a[j].v&&a[i].ans<a[j].ans)
            {
                a[i].ans=a[j].ans;
            }
        }
    }
    int sum=0;
    for (int i=1;i<=n;++i)
    {
        sum+=a[i].ans;
    }
    if (sum>w)
    {
        printf("-1\n");
        return 0;
    }
    w-=sum;
    for (int i=n;i>=1;--i)
    {
        a[i].ans+=w;
        w=0;
        if (a[i].ans>a[i].v)
        {
            w=a[i].ans-a[i].v;
            a[i].ans=a[i].v;
        }
    }
    sort(a+1,a+n+1,cmp2);
    for (int i=1;i<=n;++i)
    {
        if (i>1)
        {
            printf(" ");
        }
        printf("%d",a[i].ans);
    }

    return 0;
}
/*2018-07-21 20:44:33.948*/

#include <iostream>
#include <vector>
#include <algorithm>

bool sec_sort(const std::pair<int,int> &a,const std::pair<int,int> &b)
{
	return (a.second>b.second);
}

int main()
{
	int n,w,k,t;
	int start=0;
	std::cin>>n>>w;
	std::vector< std::pair<int,int> > v(n);
	std::vector<int> f(n,0);
	for(int i=0;i<n;i++)
	{
		std::cin>>t;
		v[i]=std::make_pair(i,t);
	}
	std::sort(v.begin(),v.end(),sec_sort);
	for(int i=0;i<n;i++)
	{
		if(v[i].second%2)
		{
			++v[i].second;
			f[i]=1;
		}
		v[i].second=v[i].second/2;
		w=w-v[i].second;
	}
	if(w<0)
	{
		std::cout<<-1<<"\n";
		return 0;
	}
	while(w>0)
	{
		if((v[start].second-f[start])>=w)
		{
			v[start].second+=w;
			w=0;
			break;
		}
		w=w-v[start].second+f[start];
		v[start].second+=v[start].second-f[start];
		start++;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(v[j].first==i)
				std::cout<<v[j].second<<" ";
		}
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int MAXN=105;
int n,k,ans[MAXN];
vector<pair<int,int> > v;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i) {
		int a;
		scanf("%d",&a);
		v.push_back(make_pair(a,i));
		ans[i]=(a+1)/2;
		k-=(a+1)/2;
	}
	if(k<0) {
		puts("-1");
		return 0;
	}
	sort(rall(v));
	for(int i=0;i<v.size();++i){
		int temp=min(k,v[i].first-ans[v[i].second]);
		ans[v[i].second]+=temp;
		k-=temp;
	}
	for(int i=0;i<n;++i) printf("%d ",ans[i]);
	puts("");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
pair<int,int>p[100000];
int main(){
	int n,w,s=0,f,oc=0;
	cin>>n>>w;
	int A[n+1],B[n+1];
	for(int i=0;i<n;i++){
		cin>>A[i];
		p[i].first=A[i];
		p[i].second=i;
		oc+=A[i];
	    B[i] = (A[i]+1)/2;
	    s += B[i];
	}

	if(oc == w){
	    for(auto i=0;i<n;i++)
	        cout<<A[i]<<" ";
	    return 0;
	}
	if(w == s){
	    for(int i=0;i<n;i++){
		    cout<<B[i]<<" ";
	    }
	}else if(w < s){
	    cout<<-1;
	}else{
	    w=w-s;
	    sort(p,p+n);
	    for(auto i=n-1;i>=0;i--){
	        int ind=p[i].second;
	        int q = p[i].first;
	        int g=q-B[ind];

	        if(w>0 and w-g>0){
	            B[ind]+=g,w=w-g;
	        }else if(w>0 and w<=g){
	            B[ind]+=w;
	            w=0;
	        }

	    }

	    for(auto i=0;i<n;i++)
	        cout<<B[i]<<" ";

	    return 0;
    }
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cassert>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <utility>
#include <cmath>
#include <list>
#include <bitset>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
#define fi first
#define se second
#define pb push_back
#define forn(i, n) for (int i = 1; i <= n; i++)
#define fore(i, n) for (int i = 0; i < n; i++)

vector<ii> vt;
vector<ii>vl;

bool cmp(ii a, ii b) {
	return a.second < b.second;
}
int main(){
	int n,m;
	cin >> n >> m;
	vt.resize(n);
	fore(i, n) {
		ii temp;
		cin >> temp.first;
		temp.second = i;
		vt[i] = temp;
	}
	vl = vt;
	sort(vt.begin(), vt.end());
	reverse(vt.begin(), vt.end());

	fore(i, n) {
		m = m - ((vt[i].first + 1) / 2);
		vt[i].first -= (vt[i].first + 1) / 2;
	}

	if (m < 0) {
		cout << "-1\n" << endl;
		return 0;
	}
	int a = 0;
	while (m > 0) {
		int t = vt[a].first;
		vt[a].first = m > t? 0 : t - m;
		m = m > t ? m - t : 0;
		a++;
	}
	sort(vt.begin(), vt.end(), cmp);
	fore(i, n) {
		if (i !=0 )cout << ' ';
		printf("%d", vl[i].first - vt[i].first);
	}

	cout << endl;

	return 0;
}

#include <bits/stdc++.h>
// vector string set map first second continue break return upper_bound lower_bound length void sort
#define FOR(i,j,n) for(int i=(j);i<=((int)n);++i)
#define N 1000005
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl
typedef long long int ll;
#define int long long int
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
vector <int>g[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
#endif
int n,t;
cin>>n>>t;
int a[n+5];
std::vector<ii> v;
for(int i = 1; i <=n; ++i)
{
	cin>>a[i];
	v.push_back({a[i],i});
}
int p=-1;
int mx=-1;
for(int i = 1; i <=n; ++i)
{
	if (mx<a[i])
	{
		mx=a[i];
		p=i;
	}
}
int c=0;
int dp[n+5]={0};
int sm=-1;
for(int i = 1; i <=n; ++i)
{

	dp[i]=(a[i]+1)/2;
	c+=dp[i];
}
int l=t-c;
if (l<0)
{
	cout<<-1<<endl;
	return 0;
}
sort(v.begin(), v.end(),greater<ii>());
for(int i = 0; i<n ; ++i)
{
	int b=v[i].first;
	int q=v[i].second;
	// cout<<q<<endl;
	if ((a[q]-dp[q])<l)
	{
		l-=(a[q]-dp[q]);
		dp[q]=a[q];
	}
	else
	{
		dp[q]+=l;
		break;
	}
}
for(int i = 1; i <=n; ++i)
{
	cout<<dp[i]<<" ";
}

}

// #Hala BBCF

#include <bits/stdc++.h>

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;

    int n,w;cin>>n>>w;
    vector<int> a(n),ans(n);
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans[i]=ceil(a[i]*1.0/2);
        v[i]={a[i],i};
        w-=ans[i];
    }
    sort(v.rbegin(),v.rend());
    if(w<0){
        cout<<-1;
    }
    else{
        for(auto x:v){
            if(w>a[x.second]/2){
                ans[x.second]=a[x.second];
                w-=a[x.second]/2;
            }
            else {
                ans[x.second]+=w;
                w=0;
                break;
            }
        }
        if(w){
            cout<<-1;
        }
        else {
            for(auto x:ans){
                cout<<x<<" ";
            }
        }
    }

    #ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v;
int a[110];
bool com(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}
int main(){
    int n,w;
    cin>>n>>w;
    int sum=0,ss=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        sum+=(x%2)+(x/2);
        ss+=x;
        v.push_back(make_pair(i,x));
    }
    if(ss==w){
        for(int i=0;i<n;i++)cout<<v[i].second<<' ';
    }
    else if(sum>w)cout<<-1<<endl;
    else{
        //cout<<1<<endl;
        int dif=w-sum;
        sort(v.rbegin(),v.rend(),com);
        for(int i=0;i<v.size();i++){
            int val=v[i].second;
            val=(val/2)+(val%2);
            if(dif){
                int vk=(v[i].second-val);
                if(dif>=vk){
                    a[v[i].first]=v[i].second;
                    dif-=(v[i].second-val);

                    }
                else{
                    a[v[i].first]=val+dif;
                    dif=0;
                }
            }
            else{
                a[v[i].first]=val;
            }
        }
        for(int i=1;i<=n;i++)cout<<a[i]<<' ';
    }
}

#include <bits/stdc++.h>
using namespace std;
struct node{
	int x,id;
	friend bool operator <(node a,node b){
		return a.x>b.x;
	}
} a[105];
int n,w,ans[105];
int main(){
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		a[i].x=x;
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		ans[a[i].id]=(a[i].x+1)/2;
		w-=ans[a[i].id];
	}
	if(w<0)	return puts("-1"),0;
	int cur=1;
	while(w>0){
//		cout<<"w="<<w<<endl;
//		cout<<a[cur].x-ans[a[cur].id]<<endl;
		if(a[cur].x-ans[a[cur].id]>=w){
			ans[a[cur].id]+=w;
			break;
		}
		else{
			w-=a[cur].x-ans[a[cur].id];
			ans[a[cur].id]=a[cur].x;
		}
		cur++;
	}
	for(int i=1;i<=n;i++)	cout<<ans[i]<<" ";
	return 0;
}

#include <bits/stdc++.h>

#define ll long long

#define pb push_back
#define mp make_pair
#define s second
#define f first

using namespace std;

int main()
{
	ll n,k,i,j;
	scanf("%lld%lld",&n,&k);
	ll arr[n];
	ll sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&arr[i]);
		sum+=(arr[i]+1)/2;
	}
	if(sum>k)
	{
		printf("-1\n");
	}
	else
	{
		vector<pair<pair<ll,ll>,ll> > v;
		sum=k-sum;
		for(i=0;i<n;i++)
		{
			v.pb(mp(mp(arr[i],(arr[i]+1)/2),i));
		}
		i=0;
		sort(v.begin(),v.end(),greater<pair<pair<ll,ll>,ll > >());
		/*cout<<"Vector is \n";
		for(i=0;i<n;i++)
		{
			cout<<v[i].f.f<<" "<<v[i].f.s<<" "<<v[i].s<<endl;
		//}*/
		for(i=0;i<n;i++)
		{
			arr[i]=(arr[i]+1)/2;
		}
		i=0;
		//cout<<"Sum is "<<sum<<endl;
		while(sum!=0)
		{
			ll curr_val=v[i].f.s,curr_index=v[i].s;
			ll can_add=v[i].f.f-curr_val;
			//cout<<"Can add is "<<can_add<<endl;
			if(can_add>=sum)
			{
				arr[curr_index]+=sum;
				sum=0;
			}
			else
			{
				sum-=can_add;
				arr[curr_index]+=can_add;
			}
			i++;
		}
		for(i=0;i<n;i++)
		{
			printf("%lld ",arr[i]);
		}
		printf("\n");
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,w,a[1000],c[1000],t=0,s=0;
pair <long long ,long long> p[1000];
main()
{
	cin>>n>>w;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		c[i]=(a[i]+1)/2;
		s+=(a[i]+1)/2;
	}
	if(w<s) {
	cout<<-1<<endl;
	return 0;
	}
	for(int i=1; i<=n; i++)
	{
		p[i].first=a[i];
		p[i].second=i;
	}
	sort(p+1,p+n+1);
	s=w-s;
	for(int i=n; i>=1; i--)
	{
		c[p[i].second]+=min(s,a[p[i].second]/2);
		s-=min(s,a[p[i].second]/2);
	}
	for(int i=1; i<=n; i++)
		cout<<c[i]<<" ";
}

#pragma comment(linker, "/STACK:216000000")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <set>
#include <bitset>
#include <sstream>
#include <array>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <tuple>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
const ll MAX = 100000000LL * 100000000LL;
const ll MIN = numeric_limits<ll>::min();
const double PI = 3.14159265358979;
const ll MOD = 1000000007LL;

template<class T>
ostream& operator<<(ostream& out, vector<T>& v) {
	for (int i = 0; i < v.size(); ++i) out << v[i] << " ";
	return out;
}

template<class T>
istream& operator >> (istream& in, vector<T>& v) {
	for (int i = 0; i < v.size(); ++i) in >> v[i];
	return in;
}

template<class L, class R>
istream& operator >> (istream& in, pair<L, R>& p) {
	in >> p.first >> p.second;
	return in;
}

template<class T>
T lexical_cast(string& s) {
	stringstream ss(s);
	T t;
	ss >> t;
	return t;
}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll cdiv(ll a, ll b) {
	return (a % b) ? (a / b + 1) : (a / b);
}

ll inv(ll n, ll mod) {
	ll pow = mod - 2;
	ll ans = 1;
	ll cur = n;
	while (pow > 0) {
		if (pow & 1) {
			ans *= cur;
			ans %= mod;
		}
		pow /= 2;
		cur *= cur;
		cur %= mod;
	}
	return ans;
}

template<class Cont> void sort(Cont& c) { sort(begin(c), end(c)); }
template<class Cont> void reverse(Cont& c) { reverse(begin(c), end(c)); }

/* ------------------------------------------------
------------------------------------------------- */

int main() {
	ios_base::sync_with_stdio(false);
#ifdef DEBUG
	ifstream cin{ "input.txt" };
	ofstream cout{ "output.txt" };
#endif
	int n, w;
	cin >> n >> w;
	vector<pair<int, int>> a(n);
	int need = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
		need += cdiv(a[i].first, 2);
	}
	if (need > w) {
		cout << -1;
		return 0;
	}
	sort(a.rbegin(), a.rend());
	vector<int> ans(n);
	int rem = w - need;
	for (int i = 0; i < n; ++i) {
		ans[i] = cdiv(a[i].first, 2);
		int cur = min(rem, a[i].first - ans[i]);
		ans[i] += cur;
		rem -= cur;
	}
	vector<int> anss(n);
	for (int i = 0; i < n; ++i) {
		anss[a[i].second] = ans[i];
	}
	cout << anss;
}

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

int main()
{
    int n,w;
    while(cin>>n>>w)
    {
        int a[n],b[n];
        int sum=0;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            b[i]=(a[i]+1)/2;
            sum+=b[i];
        }
        if(sum>w)
            cout<<-1<<endl;
        else
        {
            w-=sum;
            while(w)
            {
                int maxindex=0;
                for(int i=1;i<n;i++)
                {
                    if(a[maxindex]<a[i])
                        maxindex=i;
                }
                int temp=min(w,a[maxindex]-b[maxindex]);
                b[maxindex]+=temp;
                //cout<<b[i]<<' ';
                w-=temp;
                //cout<<w<<endl;
                a[maxindex]=0;
            }

                for(int i=0; i<n-1; i++)
                {
                    cout<<b[i]<<' ';
                }
                cout<<b[n-1]<<endl;
        }
    }
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
const int MAXN = 105;

int n,w;

int v[MAXN];
int c[MAXN];

bool flag = true;

int main(){

	memset(c,0,sizeof(c));

	cin>>n>>w;

	int minx = 0;

	priority_queue<pair<int,int>> fila;

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

		fila.push({v[i],i});

		if(v[i]%2 == 0)
			minx += v[i]/2 , c[i] += v[i]/2;
		else
			minx += v[i]/2 + 1 , c[i] += v[i]/2 + 1;
	}

	if(w < minx)
		flag = false;
	else{
		w = w - minx;

		while(w != 0){

			int s = fila.top().second;

			if(w > v[s] - c[s]){
				w -= v[s] - c[s];
				c[s] = v[s];
			}
			else{
				c[s] += w;
				w = 0;
			}

			fila.pop();
		}
	}

	if(flag == false)
		cout<<"-1";
	else{
		for(int i = 1;i <= n;i++){
			cout<<c[i]<<" ";
		}
	}

}

// 1521684601892

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int n,w;
struct lol{
	int id,isi;
};

bool cmp1(lol a, lol b)
{
	return (a.id<b.id);
}

bool cmp2(lol a, lol b)
{
	 return (a.isi>b.isi);
}

bool cmp3(int a,int b)
{
	return (a>b);
}
int dat[1000];
lol hsl[1000];
int main()
{
	scanf("%d%d",&n,&w);
	int ht=0;
	int mtot=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&dat[i]);
		ht+=(dat[i]+1)/2;
		hsl[i].isi=dat[i];
		hsl[i].id=i;
		mtot+=dat[i];
	}
	sort(hsl+1,hsl+n+1,cmp2);
	for(int i=1;i<=n;i++)
	{
		hsl[i].isi++;
		hsl[i].isi/=2;
	}
	sort(dat+1,dat+n+1,cmp3);
	if(ht>w || w>mtot) printf("-1\n");
	else
	{
		w-=ht;
		int st=1;
		while(w!=0)
		{
			//cout << w << endl;
			if(hsl[st].isi==dat[st]) st++;
			else
			{
				w-=(dat[st]-hsl[st].isi);
				hsl[st].isi=dat[st];
				if(w<0)
				{
					hsl[st].isi+=w;
					w=0;
				}
			}
		}
		sort(hsl+1,hsl+n+1,cmp1);
		for(int i=1;i<=n;i++)
		{
			if(i==1) printf("%d",hsl[i].isi);
			else printf(" %d",hsl[i].isi);
		}
		printf("\n");
	}
 	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<cctype>
#include<map>
#include<stack>
#include<cstdlib>
#include<queue>
#include<vector>
#include<algorithm>
#include<bitset>
#include<algorithm>
#include<set>
#include<limits.h>
#include <sstream>

using namespace std;
typedef long int LD;
typedef long long int LLD;
typedef float F;
typedef double LF;
typedef unsigned int U;
typedef unsigned long int LU;
typedef unsigned long long int LLU;
typedef char C;

/*----------simple input section ------------ */
#define sf scanf
#define sfi(x) scanf("%d",&x)
#define sfc(x) scanf("%c",&x)
#define sfi2(x,y) scanf("%d%d",&x,&y)
#define sfll2(x,y) scanf("%lld%lld",&x,&y)
#define sfu2(x,y) scanf("%llu%llu",&x,&y)
#define sfl(x) scanf("%ld",&x)
#define sfll(x) scanf("%lld",&x)
#define sfd(x) scanf("%lf",&x)
#define sfu(x) scanf("%llu",&x)
#define sfs(x) scanf("%s",x)

/*----------simple input section ------------ */
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%ld\n",x)
#define pfll(x) printf("%lld\n",x)
#define pfu(x) printf("%llu\n",x)
#define pfs(x) printf("%s\n",x)
#define pfc(x) printf("%c\n",x)
#define pfd(x) printf("%lf\n",x)

/*----------file input section ------------ */

#define f_input  freopen("input.txt","r",stdin);
#define f_output freopen("output.txt","w",stdout);

#define pb(x) push_back(x)
#define PI acos(-1.0)
#define sq(x) (x)*(x)
#define mem(x,y) memset(x,y,sizeof(x))
#define TEST int cs,T;sfi(T);getchar();for(cs=1;cs<=T;cs++)
#define nn printf("\n")
// xx-> diagonal -> 8 horizontal/vertical->4

const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};

// KX-> Knight moves
const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};

/******** debug **********/
#define chk1 printf("hi......1  \n")
#define chk2 printf("hi......2  \n")

#define mod 1000000007
#define eps 10e-8
#define sz 200004
#define sz1 302
#define sz2 5
/******* start my code ********/
map<int,int>mp;
map<int,int>mpN;
int arr[sz1];
int main()
{
    int i,j,k,n,w,mn,vmn;
    sfi2(n,w);
  //  k=0;
    for(i=0;i<n;i++)
    {
        sfi(arr[i]);
      //  k+=(arr[i]/2);
        if(arr[i]%2==1) k++;
        mpN[arr[i]]++;
    }
//    if(k>w)
//    {
//        pfi(-1);
//        return 0;
//    }
    for(i=1;i<=100;i++)
    if(mpN[i]){
        mn=i;
        break;
    }
    vmn=0;
    vmn=mn/2;
    if(mn%2==1) vmn++;
    bool key=0;
    int val,sum=0;
    val=vmn;
   // pfi(val);
    for(i=mn;i<=100;i++)
    {
       if(mpN[i])
       {
           val=i/2;
           if(i%2==1) val++;
           mp[i]=val;
           sum+=val*mpN[i];
          // val++;
           if(sum>w) key=1;
           if(key) break;
       }
    }
    if(key)
    {
       // chk1;
        pfi(-1);
        return 0;
    }
    key=1;
    while(sum<w)
    {
        key=0;
       // chk1;
        for(i=100;i>=mn && w-sum>=0;i--)
        {
            if(mpN[i] && mpN[i]<=(w-sum) && mp[i]<i)
            {
//                if(mp[i]+(w-sum)/mpN[i]<=i)
//                {
//                    mp[i]+=(w-sum)/mpN[i];
//                    sum+=(w-sum)/mpN[i];
//                }
//                else{
                mp[i]++;
                sum+=mpN[i];
            //    }
                key=1;
            }
        }
        if(!key) break;
    }
    int a= mp[mn];
    for(i=mn+1;i<=100;i++)
    {
        if(mpN[i])
        {
            if(mp[i]<a)
            {
                key=0;
                break;
            }
            a=mp[i];
        }
    }
    if(!key) pfi(-1);
    else
    {
        for(i=0;i<n;i++)
            pf("%d ",mp[arr[i]]);
    }
    return 0;
}
/*
4 5
1 1 1 2

3 4
1 2 2

3 10
8 4 8

*/

#include<bits/stdc++.h>

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector< int >
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i,j,n,t=1,l=0,k=0,cnt=0,mini=999999,maxi=-999999999,ans=0;
    ll m;
    ll w;
    cin>>n>>w;
    ll a[n],b[n];
    rep(i,0,n) cin>>a[i];
    ll c[n];
    rep(i,0,n)
    {
        c[i]=ceil(a[i]/2.0);
        k+=c[i];
    }
    if(w<k) ret(-1);
    w-=k;
    while(cnt<n)
    {
        ll pos=max_element(a,a+n) -a;
        if(w>a[pos]-c[pos])
            w=w-(a[pos]-c[pos]),c[pos]=a[pos];
        else c[pos]=c[pos]+w,w=0;
        a[pos]=LLONG_MIN;
        if(w==0) break;
        cnt++;
    }
    rep(i,0,n) cout<<c[i]<<" ";
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef unsigned long long int  ull;
typedef long long int  ll;
#define FR freopen("input.txt", "r", stdin);
#define FW freopen("output.txt", "w", stdout);
#define SETPRES  std::setprecision(6),std::fixed;
#define pb push_back
#define mp make_pair
#define INF 10000000
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define  Help_me  ios_base::sync_with_stdio(false);
template <class T1>
T1 GCD(T1 A,T1 B)
{
if(B==0)
return A;
else
return GCD(B,A%B);
}
template <class T2>
   T2 mulmod(T2 a,T2 b)  {T2 x=0,y=a%mod;while(b){
           if(b%2==1){x=(x+y)%mod;}
           y=(2*y)%mod;b=b/2;}return x%mod;}
template<class T3>
   T3 power(T3 a,T3 b){T3 x=1,y=a%mod;while(b){if(b%2==1){x=mulmod(x,y)%mod;}y=mulmod(y,y)%mod;b=b/2;}return x%mod;}
template<class T4>
bool cmp(T4 x,T4 y)
{
    return x>y?1:0;
}
int n,w;
vector<pair<int,int> > arr;
int ans[1000];
int main()
{
Help_me
#ifndef ONLINE_JUDGE
    //string s="646";
    //stringstream(s)>>number;
    FR
//    FW
    #endif
    cin>>n>>w;

    int xx=w;
    int x;
    for(int i=0;i<n;i++)
{
    cin>>x;

    arr.push_back(mp(x,i));
    if(x%2==0)
        x=x/2;
    else
    {
        x=x/2;
        x++;
    }
    ans[i]=x;
    w-=x;

}
if(w<0)
{
    cout<<"-1";
    return 0;
}

sort(arr.begin(),arr.end());
for(int i=n-1;i>=0;i--)
{
    int rem=(arr[i].first)/2;
    if(w>rem)
    {
        ans[arr[i].second]+=rem;
        w-=rem;
    }
    else
    {
      ans[arr[i].second]+=w;
      break;

    }
}
for(int i=0;i<n;i++)
    cout<<ans[i]<<" ";
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
struct Guest
{
	int Tea,Tea_cup,hh;
}a[110];
bool cmp(Guest a,Guest b)
{
	return a.Tea_cup>b.Tea_cup;
}
bool cmp_hh(Guest a,Guest b)
{
	return a.hh<b.hh;
}
int main()
{
	int n,m,sum=0,sum_half=0;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		a[i].hh=i;
		cin>>a[i].Tea_cup;
		a[i].Tea=(a[i].Tea_cup+1)/2;
		sum_half+=a[i].Tea;
		sum+=a[i].Tea_cup;
	}
	if(m<sum_half||m>sum) {cout<<-1;return 0;}
	m-=sum_half;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i)
	{
		while(m&&a[i].Tea<a[i].Tea_cup)
		{
			a[i].Tea++;
			m--;
		}
		if(m==0) break;
	}
	sort(a+1,a+n+1,cmp_hh);
	for(int i=1;i<=n;++i) cout<<a[i].Tea<<" ";
	return 0;
 }

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
using namespace std;
void past_code();

#define mod 300002
#define ll  long long

int main(){
	int x,w,sum=0;
	cin>>x>>w;
	pair<int,int>*y=new pair<int,int>[x];
	int *q=new int [x];
	for (int i=0;i<x;i++){
		cin>>y[i].first;
		y[i].second=i;
		sum=sum+y[i].first;
	}
	if (sum>w*2 ||w<x)
		cout<<"-1\n";
	else
	{

		sort(y,y+x);
		for (int i=0;i<x;i++)
		{
			q[i]=(y[i].first+1)/2;
			w=w-(y[i].first+1)/2;
		}
		int c=x-1;
		int kk=q[c];
		while (w>0 &&c>-1)
		{
			kk=q[c];
			q[c]=min(y[c].first,q[c]+w);
			w=w-(q[c]-kk);
			c--;
		}
		if (w>0 ||w<0)
			cout<<"-1\n";
		else{
		for (int i=0;i<x;i++)
		{
			for (int j=0;j<x;j++)
			{
				if (y[j].second==i){
					cout<<q[j]<<" ";
					break;
				}
			}
		}
		cout<<endl;
	}
	}
	return 0;
}

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

int maxv[105], ansv[105], r[105];

bool cmp(int i, int j) {
	return maxv[i] < maxv[j];
}

int main() {
	int n, w;
	scanf("%d%d", &n, &w);
	for(int i=0; i<n; i++)
		scanf("%d", &maxv[i]), r[i] = i;

	sort(r, r+n, cmp);

	ansv[r[0]] = (maxv[r[0]]+1)/2;
	w -= ansv[r[0]];
	for(int i=1; i<n; i++) {
		ansv[r[i]] = max((maxv[r[i]]+1)/2, ansv[r[i-1]]);
		if(ansv[r[i]] > maxv[r[i]]) {
			printf("-1\n"); return 0;
		}
		w -= ansv[r[i]];
	}

	if(w < 0) {
		printf("-1\n");
		return 0;
	}

	if(w > 0) {
		int d, pos = n-2;
		ansv[r[n-1]] += (d = min(w, maxv[r[n-1]]-ansv[r[n-1]]));
		w -= d;
		while(w > 0 && pos >= 0) {
			ansv[r[pos]] += (d = min(maxv[r[pos]]-ansv[r[pos]], min(w, ansv[r[pos+1]]-ansv[r[pos]])));
			w -= d; pos --;
		}
	}
	for(int i=0; i<n; i++) {
		if(i) printf(" ");
		printf("%d", ansv[i]);
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
struct Node
{
    int a;
    int ans;
    int id;
}node[103];
bool cmp1(Node A,Node B)
{
    return A.a<B.a;
}
bool cmp2(Node A,Node B)
{
    return A.id<B.id;
}
int main()
{
    int n,w;
    scanf("%d %d",&n,&w);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&node[i].a);
        node[i].id=i;
    }
    sort(node,node+n,cmp1);
    int s=(node[0].a+1)/2;
    int sum=s;
    int i=1;
    node[0].ans=s;
    bool flag=true;
    for(i=1;i<n;i++)
    {
        if((node[i].a+1)/2>s) s=(node[i].a+1)/2;
        node[i].ans=s;
        sum+=s;
        if(sum>w) flag=false;
    }
    if(!flag) printf("-1\n");
    else
    {
        i--;
        int p=w-sum;
        while(p&&i>=0)
        {
            int q=((p>(node[i].a-node[i].ans))?(node[i].a-node[i].ans):p);
            p-=q;
            node[i].ans+=q;
            i--;
        }
        if(p) printf("-1");
        else
        {
            sort(node,node+n,cmp2);
            for(int i=0;i<n;i++)
            {
                if(i!=0) printf(" ");
                printf("%d",node[i].ans);
            }
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
struct node{
	int num;
	int id;
}a[110];
int n,w,i,b[110];
bool cmp(node a,node b)
{
    return a.num>b.num;
}
int main()
{
	cin>>n>>w;
	for(i=1;i<=n;i++)
	{
		cin>>a[i].num;
		a[i].id=i;
		b[i]=(a[i].num+1)/2;
		w-=b[i];
	}
	sort(a+1,a+1+n,cmp);
	if(w<0)puts("-1");
	else
	{
		for(i=1;i<=n;i++)
		{
			if(w>=a[i].num-b[a[i].id])
			{
				w-=a[i].num-b[a[i].id];
				b[a[i].id]=a[i].num;
			}
			else
			{
				b[a[i].id]+=w;
				break;
			}
		}
		for(i=1;i<=n;i++)
		cout<<b[i]<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w,i,j,sum=0,r;
    cin>>n>>w;
    int a[n+1],b[n+1],c[105],x;
    vector<pair<int,int> >v(n);
    for(i=0;i<n;i++)
    {
         cin>>a[i];
         v[i].first=a[i];
         v[i].second=i;
         b[i]=ceil(a[i]/2.0);
         sum=sum+b[i];
    }
    if(sum>w)
    {
         cout<<-1<<endl;
         return 0;
    }

    else
       {
           sort(v.begin(),v.end());
           reverse(v.begin(),v.end());
           r=w-sum;
           j=0;
           while(r>0)
           {

                     x=v[j%n].second;
                   //cout<<v[j%n].second<<endl;
                     //return 0;
                     int t=r;
                     if(b[x]+r>a[x])
                     {
                         r=b[x]+r-a[x];
                         b[x]=a[x];
                     }
                     else
                     {
                         r=b[x]+r-a[x];
                          b[x]=b[x]+t;

                     }

                     j++;

            }
       }
       for(i=0;i<n;i++)
          cout<<b[i]<<" ";
         cout<<endl;

}

#include <bits/stdc++.h>
         #define fio             ios_base::sync_with_stdio(false),cin.tie(NULL)
         #define ll              long long int
         #define ld              long double
         #define f(a,b)          for(int i=a;i<b;i++)
         #define in(a,b)         (b.find(a) != string::npos)
         #define X               first
         #define Y               second
         #define fill(a,x)       memset(a,x,sizeof(a))
         #define pb              push_back
         #define pf              push_front
         #define mp              make_pair
         #define all(v)          v.begin(),v.end()
         #define el              "\n"
         const ll M = 1e9 + 7;
    using namespace std;
   int main(){
       fio;
       ll n,k;
       cin>>n>>k;
       ll a[n]={0};
       f(0,n)cin>>a[i];
       vector<pair<ll,ll>>v,ans;
       f(0,n){
           v.pb(mp(a[i],i));
       }
      // sort(all(v));
       map<ll,ll> m;
       ll sm=0;
       f(0,n){
             //  cout<<v[i].X<<" "<<v[i].Y<<el;
           if(v[i].X%2==1){
               m[v[i].Y]=(v[i].X)/2+1;
           }
           else
               m[v[i].Y]=(v[i].X)/2;

           sm+=m[v[i].Y];
         //  cout<<m[v[i].Y]<<el;
       }
       ll x;
       x=k-sm;
       if(x<0)cout<<-1<<el;
       else{
         // ll ans[n]={0};
          //f(0,n)ans[i]=m[i];
       //    f(0,n)cout<<ans[i]<<el;
            vector<pair<pair<ll,ll>,ll>>z;
            f(0,n){
           z.pb(mp(mp(v[i].X,v[i].Y),m[v[i].Y]));
             //   cout<<z[i].X<<" "<<z[i].Y<<el;
         }
           sort(all(z));
           int g=0,y,dif;
           for(int i=z.size()-1;i>=0&& g==0;i--){
               dif=z[i].X.X-z[i].Y;
               //cout<<dif<<el;
              // y=x-dif;
              // cout<<y<<el;
               if(dif>=x){
                   z[i].Y+=x;
                   g=1;
               }
               else{
               z[i].Y+=dif;
              }
                 x=x-dif;
               if(x<=0)g=1;
           }
          map<ll,ll> m1;
            f(0,n){
              //  cout<<z[i].X<<" "<<z[i].Y<<el;
            m1[z[i].X.Y]=z[i].Y;
        }
         f(0,n)cout<<m1[i]<<" ";
       }
       return 0;
   }

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<ctime>
#include<iomanip>
using namespace std;
int n,w;
struct A{int a,b,i;}a[105];
bool cmp(A a,A b){return a.a>b.a;}
bool cmpp(A a,A b){return a.i<b.i;}
int main(){
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		cin>>a[i].a;
		a[i].b=(a[i].a+1)/2;
		a[i].i=i;
		w-=a[i].b;
	}
	sort(a+1,a+n+1,cmp);
	if(w<0)return cout<<"-1",0;
	for(int i=1;i<=n;i++){
		if(a[i].a-a[i].b<=w){
			w-=a[i].a-a[i].b;
			a[i].b=a[i].a;
		}
		else{
			a[i].b+=w;
			break;
		}
	}
	sort(a+1,a+n+1,cmpp);
	for(int i=1;i<=n;i++) cout<<a[i].b<<" ";
	return 0;
}

#include <iostream>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;

/// Greedy
struct TeaCup{
	int dt,c,vt;
};

bool ss(TeaCup a,TeaCup b){
	return a.dt>b.dt;
}

int main() {
	int n,w;
	cin>>n>>w;
	TeaCup a[n+1];
	int b[n+1];
	int s = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i].dt;
		s+= ceil(a[i].dt * 1.0 /2);
		a[i].c= ceil(a[i].dt * 1.0 /2);
		a[i].vt=i;
	}

	sort(a+1,a+n+1,ss);
	for(int i=1;i<=n;i++){
		while(s<w && a[i].c<a[i].dt){
			s++;
			a[i].c++;
		}
		b[a[i].vt] = a[i].c;
	}

	if(s==w){
		for(int i=1;i<=n;i++) cout<<b[i]<<" ";
	}else cout<<"-1";
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iomanip>
#include <limits.h>
#include <algorithm>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <fstream>
#include <ctime>

using namespace std;

struct El {
    int idx;
    int a;

    bool operator < (El e) {
        return a > e.a;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    int n, w;
    cin >> n >> w;
    El e[n];
    int ans[n];

    for (int i = 0; i < n; i++) {
        cin >> e[i].a;
        e[i].idx = i;
        int half = ceil(e[i].a * 0.5);
        w -= half;
        ans[i] = half;
    }

    if (w < 0) {
        cout << -1;
        return 0;
    }

    sort(e, e + n);

    for (int i = 0; i < n && w > 0; i++) {
        int am = min(w, e[i].a - ans[e[i].idx]);
        w -= am;
        ans[e[i].idx] += am;
    }

    if (w > 0) {
        cout << -1;
        return 0;
    }

    for (int x : ans) {
        cout << x << " ";
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int,pair<int,int> > &a, const pair<int,pair<int,int> > &b)
{
    return (a.second.second < b.second.second);
}

int main()
{
    int a,b,t,sum=0,i;
    pair<int,pair<int,int> > res[105];
    cin>>a>>b;
    for(i=0; i<a; i++)
    {
        scanf("%d",&t);
        res[i].first=t;
        res[i].second.first=ceil((float)t/2);
        sum+=ceil((float)t/2);
        res[i].second.second=i;
    }
    sort(res,res+a);
    b-=sum;
    if(b<0)
    {
        cout<<-1;
        return 0;
    }
    for(i=a-1; i>=0 && b>0; i--)
    {
        if(res[i].first-res[i].second.first<b)
        {
            b-=(res[i].first-res[i].second.first);
            res[i].second.first=res[i].first;
        }
        else
        {
            if(res[i].second.first+b<=res[i].first)
            {
                res[i].second.first+=b;
                b=0;
            }
        }
    }
    if(b>0)
    {
        cout<<-1;
        return 0;
    }
    sort(res,res+a,sortbysec);
    for(i=0; i<a; i++)
        printf("%d ",res[i].second.first);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int n,w;
vector <pair <int,int> > a;
int ans[200];

int main()
{
  cin >> n >> w;
  for(int i = 0; i < n; i++)
    {
      int temp; cin >> temp;
      a.push_back(make_pair(temp,i));
    }

  sort(a.begin(),a.end());
  for(int i = 0; i < n; i++)
    {
      int amount = ceil((double)a[i].first / 2);
      if(w - amount < 0)
	{
	  cout << -1;
	  return 0;
	}
      ans[a[i].second] = amount;
      w -= amount;
    }
  if(w > 0)
    {
      for(int i = n-1; i >= 0; i--)
	{
	  if(w == 0)
	    break;
	  int amount = a[i].first - ans[a[i].second];
	  if(w - amount < 0)
	    amount = w;
	  ans[a[i].second] += amount;
	  w -= amount;
	}
    }
  if(w > 0)
    {
      cout << -1;
      return 0;
    }
  for(int i = 0; i < n;i++)
    cout << ans[i] << " ";
  return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

#define _ ios::sync_with_stdio(false)
const int MAXN = 110;
const int INF=0x7fffffff;

int n;
struct cup{
    int num;
    int m;
    int t;
}a[MAXN];
int cmp(cup x,cup y){
    return x.m<y.m;
}
int cc(cup x,cup y){
    return x.num<y.num;
}
int main(){
    int w;
    scanf("%d%d",&n,&w);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i].m);
        a[i].num=i;
    }
    int MAX=0;
    int ok=1;
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        int x=(a[i].m+1)/2;
        //cout<<x<<endl;
        if(w<x){
            ok=0;
            break;
        }
        if(i==n){
            x=w;
            if(a[i].m<x){
                w-=(a[i].m-a[i].t);
                a[i].t=a[i].m;
                for(int j=n-1;j>=1;j--){
                    int y=a[j].m;
                    y=min(w+a[j].t,y);
                    w-=(y-a[j].t);
                    a[j].t=y;
                    if(w<=0)
                        break;
                }
                if(w>0){
                    ok=0;
                    break;
                }
            }else{
                a[i].t=x;
            }
        }
        if(i!=n)
            a[i].t=x;
        w-=x;
    }
    if(!ok){
        puts("-1");
        return 0;
    }
    sort(a+1, a+n+1, cc);
    for(int i=1;i<=n;i++){
        printf("%d%c",a[i].t,i==n?'\n':' ');
    }
}

//ZA
#include <bits/stdc++.h>

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 2e5 + 100;
const int mod = 1e9 + 7;

void hey () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main () {
	hey();
	int n, w;
	cin >> n >> w;
	pair<int,int> a[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i].F;
		a[i].second = i;
	}
	sort(a + 1, a + n + 1);
	int b[n + 1];
	int all = 0;
	for (int i = 1; i <= n; i++) {
		b[a[i].S] = (a[i].first + 1) / 2;
		all += (a[i].F + 1) / 2;
	}
	if (all > w) {
		cout << -1;
		return 0;
	}
	w -= all;
	for (int i = n; i >= 1; i--) {
		int x = min(w, a[i].first - b[a[i].second]);
		b[a[i].S] += x;
		w -= x;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << b[i] << " ";
	}

}

#include <stdio.h>
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct pos
{
    int x,nom;
    pos(){}
    pos (int x,int nom)
    :x(x),nom(nom){}
};
bool cmp(pos l,pos r)
{
    return l.x>r.x;
}
int summ[1001],a[1001];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    vector<pos> v;
    for (int i=1;i<=n;i++)
    {
        v.push_back(pos(a[i],i));
    }
    sort(v.begin(),v.end(),cmp);
    for (int i=0;i<n;i++)
    {
        int nom=v[i].nom;
        int kol=v[i].x/2;
        if (v[i].x%2==1) kol++;
        summ[nom]=kol;
        k-=kol;
    }
    //for (int i=1;i<=n;i++)
    //    printf("%d ",summ[i]);
    //printf("\n----------\n");
    //printf("%d\n",k);
    if (k<0)
    {
        printf("-1");return 0;
    }
    else
    {
        if (k==0)
        {
            for (int i=1;i<=n;i++)
                printf("%d ",summ[i]);
        }
        else
        {
            int l=0;
            while (k>0 && l!=n)
            {
                //printf("%d %d\n",v[l].x,v[l].nom);
                int nom=v[l].nom;
                int kol=summ[nom];
                int vms=v[l].x;
                 //printf("%d %d %d %d %d %d\n",nom,kol,vms,summ[nom],k,l);
                summ[nom]+=min(vms-kol,k);
                k-=min(vms-kol,k);
                l++;
               // printf("%d %d %d %d %d %d\n",nom,kol,vms,summ[nom],k,l);
            }
            if (k>0)
                printf("-1");
            else
            {
                for (int i=1;i<=n;i++)
                    printf("%d ",summ[i]);
            }
        }
    }

}

#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <queue>
#include <set>
#include <iomanip>
#include <stack>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long LL;
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int MAXN = 3e5 + 5;
struct cup {
    int n,index;
} a[MAXN];
bool cmp(const cup&a,const cup&b) {
    return a.n<b.n;
}
int ans[MAXN];
int main() {
    int n,w;
    cin>>n>>w;
    for(int i=0; i<n; i++) {
        scanf("%d",&a[i].n);
        a[i].index=i;
    }
    sort(a,a+n,cmp);
    int pre=(a[0].n+1)/2;
    ans[a[0].index]=pre;
    int cnt=pre;
    for(int i=1; i<n; i++) {
        if(a[i].n==a[i-1].n) {
            ans[a[i].index]=max((a[i].n+1)/2,pre);
            pre=ans[a[i].index];
        } else {
            ans[a[i].index]=max((a[i].n+1)/2,pre);
            pre=ans[a[i].index];
        }
        cnt+=pre;
    }
    if(cnt>w) {
        puts("-1");
        return 0;
    } else if(cnt<w) {
        int last=n-1;
        while(cnt<w&&last>=0) {
            if(w-cnt>=a[last].n-ans[a[last].index]) {
                cnt+=a[last].n-ans[a[last].index];
                ans[a[last].index]+=a[last].n-ans[a[last].index];
            } else {
                ans[a[last].index]+=w-cnt;
                cnt+=w-cnt;
            }
            last--;
        }
    }

        for(int i=0; i<n; i++)
            printf("%d ",ans[i]);

}

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;

const int mx=105;

struct node{
    int v;
    int c;
    int id;
}cup[mx];

bool cmp1(node a,node b)
{
    return a.v>b.v;
}

bool cmp2(node a,node b)
{
    return a.id<b.id;
}

int main()
{
    int n,i,w,v;
    scanf("%d%d",&n,&w);
    for(i=0;i<n;i++)
    {
        scanf("%d",&v);
        cup[i].id=i;
        cup[i].v=v;
        cup[i].c=0;
    }
    for(i=0;i<n;i++)
    {
        cup[i].c+=(cup[i].v+1)/2;
        w-=(cup[i].v+1)/2;
        if(w<0)
        {
            printf("-1\n");
            return 0;
        }
    }
    sort(cup,cup+n,cmp1);
    for(i=0;i<n;i++)
    {
        if(w>=(cup[i].v-cup[i].c))
        {
            w-=(cup[i].v-cup[i].c);
            cup[i].c=cup[i].v;
        }
        else
        {
            cup[i].c+=w;
            break;
        }
    }
    sort(cup,cup+n,cmp2);
    for(i=0;i<n;i++)
    {
        printf("%d",cup[i].c);
        if(i==n-1) puts("");
        else printf(" ");
    }
}
/*2018-07-21 21:29:50.67*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define mod 1000000007
#define INF 10000000000000
#define mt make_tuple
#define g0 get<0>
#define g1 get<1>
#define g2 get<2>
#define out(x) cout<<x<<endl;
#define scan(x) cin>>x;

using namespace std;

 bool sortbysec(const pair<double,int> &a,const pair<double,int> &b)
{
    return (a.second < b.second);
}

bool sortbysectuple(const tuple<int, int, int>& a,const tuple<int, int, int>& b)
{
    return (get<1>(a) < get<1>(b));
}

bool sortbyth(const tuple<ll, ll, ll>& a,const tuple<ll, ll, ll>& b)
{
    return (get<2>(a) < get<2>(b));
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);auto hash2 = hash<T2>{}(p.second); return hash1 ^ hash2;
    }
};
ll modpow(ll x,ll y){

  if(y==0) return 1;
  ll u=modpow(x,y/2);
  u=(u*u)%mod;
  if(y%2==1) u=(u*x)%mod;
  return u;
}
ll solution(ll a,ll b,ll &x,ll &y){
  if(b==0){
    x=1;
    y=0;
    return a;
  }
  ll x1,y1;
  ll g=solution(b,a%b,x1,y1);
  x=y1;
  y=x1-y1*(a/b);
  return g;
  // x=x0+k*(b/g) y=y0-k*(a/g) all solutions
}

int main(){

       ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      //  priority_queue<int, vector<int>, greater<> > Q;
	   unordered_map<pair<int, int>, string, hash_pair> um,ba;

         ll n,t,x,sum=0,ma=0,ind=-1,i,prev;

         cin>>n>>t;
         ll a[n];

         vector<pair<ll,ll>>v;

         for(i=0;i<n;i++){
         cin>>x;
         a[i]=x;
         v.pb(mp(x,i));
        }

         sort(v.begin(),v.end());

         int ans[n];

         memset(ans,0,sizeof(ans));

         prev=v[0].fi;
         ma=v[0].fi/2;
         if(v[0].fi%2!=0)
         ma++,sum+=ma;
         else
         sum+=ma;

         v[0].fi=ma;

         for(i=1;i<n;i++){

          x=v[i].fi;
          x/=2;
          if(v[i].fi%2!=0)
          x++;

          if(v[i].fi>prev && ma>=x)
          x=ma,ma=x;
          else if(v[i].fi==prev && ma>x)
          x=ma,ma=x;
          else
          ma=x;

          prev=v[i].fi;

          v[i].fi=x;
          sum+=v[i].fi;
         //cout<<v[i].fi<<" "<<a[v[i].se]<<endl;
        }

//         cout<<sum<<endl;

         if(t<sum){
         cout<<-1<<endl;
         return 0;
        }

          //v[n-1].fi+=(t-sum);
          ll rem=(t-sum);

          for(i=n-1;i>=0;i--){

             if(a[v[i].se]-v[i].fi>=rem)
             v[i].fi+=rem,rem=0;
             else
             rem-=(a[v[i].se]-v[i].fi),v[i].fi=a[v[i].se];
            //  cout<<rem<<endl;
             if(rem==0)
             break;
          }

          sort(v.begin(),v.end(),sortbysec);

          for(i=0;i<n;i++){

            cout<<v[i].fi<<" ";
          }

          //

          return 0;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
		//for getting input from input1.txt
		freopen("input1.txt","r",stdin);
		//for getting output from output.txt
		freopen("output.txt","w",stdout);
	#endif
	int n, w, i, sum=0, j;
	cin>>n>>w;
	vector<int>m(n),s(n),c(n),res(n,-1);
	for(i=0;i<n;i++){
		cin>>m[i];
		c[i]=m[i];
	}
	sort(m.begin(),m.end(),greater<int>());
	for(i=0;i<n;i++){
		s[i]=(m[i]+1)/2;
		sum+=s[i];
//		cout<<s[i]<<" "<<m[i]<<endl;

	}
//	cout<<sum<<" "<<w<<endl;
	w-=sum;
	if(w>=0){
		for(i=0;i<n;i++){
//			cout<<w<<endl;
			if(s[i]+w>m[i]){
				w=w-(m[i]-s[i]);
				s[i]=m[i];
				for(j=n-1;j>=0;j--){
					if(c[j]==m[i] && res[j]==-1 ){
						res[j]=s[i];
						break;
					}
				}

			}
			else{
				s[i]+=w;
				w=0;
	for(j=n-1;j>=0;j--){
					if(c[j]==m[i] && res[j]==-1 ){

						res[j]=s[i];
						break;
					}
				}
			}

		}
		for(i=0;i<n;i++){
			cout<<res[i]<<" ";
		}
	}
	else{
		cout<<"-1";
	}
}

#include <bits/stdc++.h>
using namespace std;
int dp[500];
bool cmp(const pair<int,int> &a, const pair<int,int> &b) { return a.first>b.first;}
int main()
{
	int n,w,sum=0; scanf("%d %d",&n,&w);
	vector<pair<int,int> > ans;
	for(int i=0;i<n;i++)
	{
		int x; scanf("%d",&x); ans.push_back(make_pair(x,i));
		dp[i]=(ans[i].first-1)/2+1; w-=(ans[i].first-1)/2+1;
	}
	sort(ans.begin(),ans.end(),cmp);
	if(w<0) return !printf("-1");
	for(int i=0;i<n;i++)
	{
		//printf("%d\n",w);
		int val=dp[ans[i].second];
		dp[ans[i].second]+=min(w,ans[i].first-dp[ans[i].second]);
		w-=min(w,ans[i].first-val);

	}
	for(int i=0;i<n;i++) printf("%d ",dp[i]);
}

#include <iostream>
#include <vector>
#include <algorithm>

bool sec_sort(const std::pair<int,int> &a,const std::pair<int,int> &b)
{
	return (a.second>b.second);
}

int main()
{
	int n,w,k,t;
	int start=0;
	std::cin>>n>>w;
	std::vector< std::pair<int,int> > v(n);
	std::vector<int> f(n,0);
	for(int i=0;i<n;i++)
	{
		std::cin>>t;
		v[i]=std::make_pair(i,t);
	}
	std::sort(v.begin(),v.end(),sec_sort);
	for(int i=0;i<n;i++)
	{
		if(v[i].second%2)
		{
			++v[i].second;
			f[i]=1;
		}
		v[i].second=v[i].second/2;
		w=w-v[i].second;
	}
	if(w<0)
	{
		std::cout<<-1<<"\n";
		return 0;
	}
	while(w>0)
	{
		if((v[start].second-f[start])>=w)
		{
			v[start].second+=w;
			w=0;
			break;
		}
		w=w-v[start].second+f[start];
		v[start].second+=v[start].second-f[start];
		start++;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(v[j].first==i)
				std::cout<<v[j].second<<" ";
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
struct node
{
	long long s,si,i,ans;
}a[106];
bool operator < (const node a,const node b)
{
	return a.si>b.si;
}
bool cmp(node a,node b)
{
	return a.i<b.i;
}
long long ans,w,n,hh;
int main()
{
	scanf("%lld%lld",&n,&w);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i].s);
		a[i].si=a[i].s;
		a[i].i=i;
		hh=(a[i].s+1)/2;
		ans+=hh;
		a[i].ans=hh;
		a[i].s-=hh;
	}
	if(ans>w)
	{
		printf("-1");
		return 0;
	}
	sort(a+1,a+n+1);
	w-=ans;
	for(int i=1;i<=n;i++)
	{
		if(w>a[i].s)
		{
			w-=a[i].s;
			a[i].ans+=a[i].s;
		}
		else
		{
			a[i].ans+=w;
			break;
		}
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	printf("%lld ",a[i].ans);
	return 0;
}

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll n, w;
	cin>>n>>w;
	vector<pair<double, int> > a(n);
	vector<ll> t(n, 0);
	REP(i, n) {
		cin>>a[i].first;
		a[i].second = i;
	}
	sort(ALL(a));
	bool det = true;
	REP(i, n) {
		if((int)(a[i].first + 0.0000001) % 2 == 0) {
			t[a[i].second] = (int)(a[i].first + 0.0000001) / 2;
			w -= (int)(a[i].first + 0.0000001) / 2;
		} else {
			t[a[i].second] = (int)(a[i].first + 0.0000001) / 2 + 1;
			w -= (int)(a[i].first + 0.0000001) / 2 + 1;
		}
		if(w < 0) det = false;
	}
	if(!det) {
		cout<<-1<<endl;
		return 0;
	}
	REP(i, n) {
		if((int)(a[n - 1 - i].first + 0.0000001) - t[a[n - 1 - i].second] <= w) {
			w -= (int)(a[n - 1 - i].first + 0.0000001) - t[a[n - 1 - i].second];
			t[a[n - 1 - i].second] = (int)(a[n - 1 - i].first + 0.0000001);
		} else {
			t[a[n - 1 - i].second] += w;
			w = 0;
			break;
		}
	}
	REP(i, n) {
		cout<<t[i];
		if(i != n - 1) cout<<" ";
		else cout<<endl;
	}
}

#include<stdio.h>
#include<algorithm>
int n,k,w,i,x,ans[110],ans2[110];
struct node{
	int val,ind;
	bool operator<(const node &p)  const{
		return p.val > val;
	}
}a[110];
int max(int a,int b){
	return a > b ? a : b;
}
int main(){
	scanf("%d%d",&n,&w);
	for(i = 0; i < n; i++){
		scanf("%d",&a[i].val);
		a[i].ind = i;
		x += (a[i].val + 1) / 2;
	}

	std::sort(a,a + n);
	for(i = 0; i < n; i++){
		if(i == 0){
			ans[i] = (a[i].val + 1) / 2;
			if(w < ans[i] || ans[i] > a[i].val) {
				printf("-1\n");
				return 0;
			}
		}
		else{
			ans[i] = (a[i].val + 1) / 2;
			if(a[i].val > a[i - 1].val){
				if(ans[i] < ans[i - 1]) ans[i] = ans[i - 1];
			}
			if(w < ans[i] || ans[i] > a[i].val){
				printf("-1\n");
				return 0;
			}
		}
		w -= ans[i];
	}
	ans[n - 1] += w;
	if(ans[n - 1] > a[n - 1].val){
		w = 0;
		for(i = n - 1; i >= 0; i--){
				if(ans[i] > a[i].val){
					if(i > 0){
						ans[i - 1] += ans[i] - a[i].val;
					}
					else{
						printf("-1\n");
						return 0;
					}
					ans[i] = a[i].val;
				}
		}
		if(w != 0){
			printf("-1\n",w);
			return 0;
		}
	}
	for(i = 0; i < n; i++){
		ans2[a[i].ind] = ans[i];
	}
	for(i = 0; i < n; i++){
		printf("%d ",ans2[i]);
	}
}

#include <iostream>
#include <algorithm>

using namespace std;

const int NMAX = 100 + 5;

int N, W;

pair <int, int> v[NMAX];
int a[NMAX];

int main()
{
    cin >> N >> W;
    for (int i = 1; i <= N; ++ i) {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v + 1, v + N + 1);

    for (int i = 1; i <= N; ++ i) {
        a[v[i].second] = (v[i].first + 1) / 2;
        W -= a[v[i].second];
    }

    if (W < 0) {
        cout << "-1\n";
        return 0;
    }

    for (int i = N; i; -- i) {
        while (W && a[v[i].second] < v[i].first) {
            -- W;
            ++ a[v[i].second];
        }
    }

    for (int i = 1; i <= N; ++ i)
        cout << a[i] << " \n"[i == N];
    return 0;
}

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

int main() {
	ll n,w,i,s,k,l;
	cin>>n>>w;

	ll a[n+5],b[n+5];
	vector < pair< ll ,ll> > m;
	vector< pair< ll ,ll> >:: iterator it;

	s=0;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		m.pb(mp(a[i],i));
		if(a[i]%2==0)
		 b[i]=a[i]/2;
		else
		 b[i]=a[i]/2+1;
		//cout<<b[i]<<' ';
		s+=b[i];

    }

    sort(m.begin(),m.end());

	//cout<<s<<' ';
	if(s>w)
	{
		cout<<-1;
		return 0;

	}

	l=w-s;
	//cout<<l<<' ';
	if(l>0)
	{
	it=m.end();
	it--;
	//cout<<m.size()<<' ';

	for( ; it!=m.begin();it--)
	{

		 k=(*it).second;
		 //cout<<a[k]<<' '<<b[k]<<' ';
		 if(l>=(a[k]-b[k]))
		 {

		 	l=l-(a[k]-b[k]);
		 	b[k]=a[k];

		 	//cout<<l<<' ';
		 }
		 else
		 {

		 	b[k]+=l;
		 	l=0;
		 	break;
		 }
	}
	if(it==m.begin() && l!=0)
	{
	k=(*it).second;
		 if((l>=(a[k]-b[k])))
		 {
		 	l-=(a[k]-b[k]);
		 	b[k]=a[k];

		 }
		 else
		 {
		 	b[k]+=l;
		 	l=0;

		 }
	}

	//cout<<l<<' ';

    if(l!=0)
    {
    	cout<<-1;
    	return 0;
    }
	}
		for(i=0;i<n;i++)
		{

			 cout<<b[i]<<' ';

		}
}

//NAME-ADITYYA OJHA
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */
#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fas1  ios_base::sync_with_stdio(false)
#define fas2   cin.tie(NULL)
#define fas3   cout.tie(NULL)
#define  f   first
#define  s   second
#define mod 1000000007
 const ll N=2e5+5;
using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting

int main ()
{
    fas1,fas2,fas3;
  ll n,w;
   cin>>n>>w;
   ll a[n];

   forin cin>>a[i];
   ll b[n];
   memset(b,0,sizeof(b));
   forin
   {
       if(a[i] & 1)
        b[i]=a[i]/2+1;
       else
        b[i]=a[i]/2;
   }

   ll c[n];
   memset(c,0,sizeof(c));
   ll z1=w;
   forin
   {

        c[i]=min(b[i],z1/n);
        if(w-c[i]>=0)
        {
            w-=c[i];
        }else
        c[i]=0;

   }
     forin
        {
            if(b[i]>c[i])
            {
              ll z=b[i]-c[i];
              if(w-z>=0)
              {
                  w-=z;
                  c[i]=b[i];
              }else
              {
                  cout<<-1<<endl;
                  return 0;
              }
            }
        }

        vector<pair<ll,ll>>mp;
        for(int i=0;i<n;i++)
        {  ll mp1=a[i];
            mp.pb({mp1,i});
        }
        sort(mp.begin(),mp.end());
        //cout<<w<<endl;
        for(int i=n-1;i>=0;i--)
        {
            ll z=min(mp[i].f-c[mp[i].s],w);
           w-=z;
           c[mp[i].s]+=z;
        }
        if(w)
            cout<<-1<<endl;
        else
        {
            forin
        cout<<c[i]<<" ";
        cout<<endl;
        }

}

/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 110;

int n, w;
int a[MAXN], b[MAXN], c[MAXN], mn = INF;

bool cmp(int x, int y){
    return (a[x] > a[y]);
}

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n >> w;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        b[i] = (a[i] + 1) / 2;
        w -= (a[i] + 1) / 2;
        c[i] = i;
        mn = min(mn, (a[i] + 1) / 2);
    }
    if (w < 0){
        cout << -1;
        return 0;
    }
    while (w >= n && mn){
        for (int i = 1; i <= n; ++i)
            if (a[i] > b[i])
                --w, ++b[i];
        --mn;
    }
    sort (c + 1, c + n + 1, cmp);
    while (w > 0){
        for (int i = 1; i <= n && w > 0; ++i){
            if (a[c[i]] > b[c[i]]){
                --w, ++b[c[i]];
            }
        }
    }
    for (int i = 1; i <= n; ++i){
        if ((a[i] + 1) / 2 > b[i]){
            cout << -1;
            return 0;
        }
        for (int j = i + 1; j <= n; ++j)
            if (a[i] > a[j] && b[i] < b[j]){
                cout << -1;
                return 0;
            }
    }
    for (int i = 1; i <= n; ++i)
        cout << b[i] << " ";
    return 0;
}

#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int n, w;
struct data{
	int first, second;
}a[105];
int rs[105];
int sum;
bool cmp(data x, data y)
{
	return x.first > y.first;
}
bool resort(data x, data y)
{
	return x.second < y.second;
}
int main()
{
	cin >> n >> w;
	int s = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		a[i].first = t;
		a[i].second = i;
		if (t % 2) sum += t / 2 + 1;
		else sum += t / 2;
		s += a[i].first;
	}
	sort(a,a + n,cmp);
	if (w > s) { cout << -1; return 0; }
	if (sum > w) { cout << -1; return 0; }
	else
	{
		int t = w - sum;
		for (int i = 0; i < n; i++)
		{
			int temp = a[i].first / 2;
			a[i].first%2 ? temp++ : 0;
			if (t)
			{
				if (t > a[i].first - temp)
					t -= a[i].first - temp;
				else
					a[i].first = temp + t,t=0;
			}
			else a[i].first = temp;
		}
	}
	sort(a, a + n, resort);
	for (int i = 0; i < n; i++)
		cout << a[i].first<<" ";
}

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int b,c;

}a[155];
int cmp(node a,node b)
{
    return a.b < b.b;
}
int d[155];
int main()
{
    int n,w,flag=0;
    while(cin >> n >> w){
        memset(d,0,sizeof(d));
        flag = 0;
        int ans = 0;
        for(int i = 1;i <= n;i ++){
            cin >> a[i].b;
            a[i].c = i;
            ans += ceil(a[i].b/2.0);
        }
        if(ans > w){
            cout << -1 << endl;
            continue;
        }
        sort(a+1,a+1+n,cmp);
        int i = 1;
        while(i <= n){
            int k = ceil(a[i].b/2.0);
            w -= k;
            d[a[i].c] = k;
            if(w < 0){
                cout << -1 << endl;
                flag = 1;
                break;
            }
            i ++;
        }
        if(w >= 0){
            for(int i = n;i >= 1;i --){
                if(w <= 0) break;
                int k = w;
                w -= min(a[i].b-d[a[i].c],w);
                d[a[i].c] = d[a[i].c] + min(a[i].b-d[a[i].c],k);
            }
            cout << d[1];
            for(int i = 2;i <= n;i ++)
                 cout <<" "<<d[i];
            cout << endl;
        }
    }
    return 0;
}

/* THE BLIND CODER */

/*
    DOMINGO
─────────▄──────────────▄
────────▌▒█───────────▄▀▒▌
────────▌▒▒▀▄───────▄▀▒▒▒▐
───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌
──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌
──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌
─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
─▌▀▐▄█▄█▌▄▒▀▒▒▒▒▒▒░░░░░░▒▒▒▐ Wow
▐▒▀▐▀▐▀▒▒▄▄▒▄▒▒▒▒▒░░░░░░▒▒▒▒▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒░░░░░░▒▒▒▐
─▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
─▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐
──▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▌
────▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
───▐▀▒▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀
*/

#include<bits/stdc++.h>
using namespace std;
main()
{
long int n,k;
	long long int  b,c,x,i,j,sum=0,rem=0,sum2=0,q=0;
	cin>>n>>k;
	vector< pair <int,int> > v2,v3,v;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		v2.push_back(make_pair(x,(x+1)/2));
		v3.push_back(make_pair(x,i));

	     sum+=(x+1)/2;
	     sum2+=x;
	     if(sum>k)
			{
				cout<<"-1";
		 return 0;
		 }
	}
	if(sum2<k)
		{cout<<"-1";
	return 0;}

	rem=k-sum;

			sort(v2.begin(),v2.end());

			sort(v3.begin(),v3.end());

		/*for(i=0;i<n;i++)
		cout<<v2[i].first<<" "<<v2[i].second<<endl;*/

	for(i=n-1;i>=0;i--)
	{
		x=v2[i].first-v2[i].second;

		if(x<=rem)
			{
				q=x;
			rem-=x;}
		else                                                // FUCK OFF
			{
				q=rem;
				rem=0;}
				//cout<<v2[i].second<<" "<<v3[i].second<<endl;
		v.push_back(make_pair(v3[i].second,((v2[i].second)+q)));

	}

		sort(v.begin(),v.end());

		for(i=0;i<n;i++)
		cout<<v[i].second<<" ";
		}

#include <bits/stdc++.h>

#define ll long long

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int lcm(int a,int b){return ((a*b)/gcd(a,b));}

using namespace std;

vector < pair < ll,ll> > v;

bool com(pair < ll ,ll> a, pair < ll , ll > b)
{
    return a.first > b.first;
}
ll arr[10003];
int main()
{
    ll i,j,k,l,m,n,w,tot=0;
    cin >> n >> w;
    for(i=01;i<=n;i++)
    {
        cin >> m;
        v.push_back(make_pair(m,i));
        tot+= (m/2) + (m%2);

    }
    sort(v.begin(),v.end(),com);
    if(w< tot)
    {
        cout << -1;
        return 0;
    }
    w-=tot;
    for(auto it: v)
    {
        m= it.first;
        ll yy= it.second;
      //  cout << m << " " << yy << endl;
        arr[it.second]=((m+1)/2) ;

        k = w-arr[it.second];
        if(k<0)
        {
            arr[it.second]+= w;
            w=0;
        }
        else
        {
            w+=arr[it.second];
            w-=m;
            arr[it.second]=m;
        }

    }
    if(w>0)
    {
        cout << 0-1;
        return 0;
    }
    for(i=1;i<=n;i++)
    {
        cout << arr[i] <<  " ";
    }

}

#include <iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;
int functions(int [],int );
int main()
{
    int n,w;

    cin>>n>>w;
    int a[n],b[n];
    int temp=0;
    int max=1000;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        temp=temp+ceil((float)a[i]/2);
        b[i]=ceil((float)a[i]/2);

    }

    if(temp>w)
    {
        temp=-1;
        cout<<temp;
    }
    else if(temp==w)
    {
        for(int i=0;i<n;i++)
            cout<<b[i]<<" ";
    }

    else
    {
        while(temp!=w)
        {
        int pos,max=0;
        for(int i=0;i<n;i++)
            if(max<a[i])
            {
                max=a[i];
                pos=i;
            }
                b[pos]++;
                temp++;
                if(b[pos]==a[pos])
                    a[pos]=0;

        }
        for(int i=0;i<n;i++)
            cout<<b[i]<<" ";
    }
    return 0;
}

int functions(int a[],int n)
{
    int pos,max;
    for(int i=0;i<n;i++)
        if(max<a[i])
        {
            max=a[i];
            pos=i;
        }
        return pos;
}

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#define ll long long int
#define ld long double
#define PB push_back
#define MP make_pair
#define INF 1000000007
using namespace std;

int n,m,i,j,k,w;

int main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 /*freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
 */

cin>>n>>w;
int w1,w2=w;
int a[n],sum=0,b[n];
pair<int,int> v[n];
for(i=0;i<n;i++)
{
	cin>>a[i];
	v[i]=MP(a[i],i);

	b[i]=ceil(a[i]*1.0/2);
	w-=b[i];
		sum+=b[i];
}
sort(v,v+n);
//cout<<w<<" ";
for(j=n-1;j>=0;j--)
{	i=v[j].second;
	if(w>a[i]-b[i])
	{ w=w-a[i]+b[i];
		b[i]=a[i];

	}
	else if(w>0)
	{
		b[i]+=w;
		w=0;
	}
	else if(w<=0)
	break;
	//cout<<w<<" ";
}

//cout<<w<<" ";
if(w!=0)
{
	cout<<-1;
}
else
{
	for(i=0;i<n;i++)
	{
		cout<<b[i]<<" ";
	}
}
return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;

struct st
{
	int x,y;
};
//

bool comp(pair<int, int> a, pair<int,int> b)
{
	if (a.first<b.first)
		return true;
	return false;
}

int main()

{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);

	/*int n;
	cin>>n;

	vector<long long> vec(n);
	long long pref=0, len=1, sum=0;
	for (int i=0;i<n;i++)
	{
		cin>>vec[i];
		sum+=vec[i];
	}

	for (int i=0;i<n;i++)
	{
		pref+=vec[i];
		for (int j=0;j<len;j++)
		{
			if (2*(pref-vec[j]) == sum)
			{
				cout<<"YES";
				return 0;
			}
		}
		len++;
	}

	cout<<"NO";*/

	int n, w;
	cin>>n>>w;
	vector<pair<int ,int> > a(n);
	vector<int> b(n,0);

	for (int i=0;i<n;i++)
	{
		cin>>a[i].first;
		b[i]=(a[i].first+1)/2;
		a[i].second=i;
		w-=b[i];
	}

	if (w<0)
	{
		cout<<-1;
		return 0;
	}

	sort(a.begin(), a.end(), &comp);

	int i=a.size()-1;
	int bb;
	while (w>0 && i>=0)
	{
		bb=b[a[i].second];
		b[a[i].second] += min(w, abs(a[i].first-bb));
		w-= min(w, abs(a[i].first-bb));
		i--;
	}

	for (i=0;i<n;i++)
		cout<<b[i]<<" ";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
int main(){
    int n,w;
    cin>>n>>w;
    vector<p> v(n);
    vector<int> r(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        v[i].second=i;
        r[i]=(v[i].first+1)/2;
        w-=r[i];
    }
    if(w<0){
        puts("-1");return 0;
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<n;i++){
        int mm=min(v[i].first-r[v[i].second],w);
        r[v[i].second]+=mm;
        w-=mm;
    }
    for(int i=0;i<n;i++)
    if(i==0)cout<<r[i];
    else cout<<" "<<r[i];
    return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x);putchar(' ');}

template<class T>inline void println(T x) {print(x);putchar('\n');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 2222

int a[NN], b[NN];

pii p[NN];

int main(){

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	int n, w;

	cin>>n>>w;

	for (int i=0; i<n; i++) {

		scanf("%d", a+i);

		p[i]=mp(a[i], i);

	}

	sort(p, p+n);

	for (int i=0; i<n; i++) {

		w-=(p[i].x+1)/2;

		int u=p[i].y;

		b[u]+=(p[i].x+1)/2;

		if (w<0) {

			puts("-1");

			return 0;

		}

	}

	for (int i=n-1; i>=0; i--) {

		int u=p[i].y;

		int ww=min(w, a[u]-b[u]);

		w-=ww;

		b[u]+=ww;

		if (!w) break;

	}

	for (int i=0; i<n; i++) printf("%d ", b[i]);

	return 0;

}

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long int
#define vi vector<int>
#define vl vector<LL>
#define pb push_back
#define all(V) V.begin(),V.end()
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%I64d",&x)
#define pii pair<int,int>
#define cmax(a,b) ((a) = (a) > (b) ? (a) : (b))
#define cmin(a,b) ((a) = (a) < (b) ? (a) : (b))
#define debug(x)  cerr << #x << " = " << x << endl
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};

void solve(){
    int n, m;
    sci(n); sci(m);
    vector<pii> A(n);
    vi B(n);
    for(auto &x : A) sci(x.first);
    for(int i = 0; i < n; i++) A[i].second = i;
    sort(all(A));
    for(int i = 0; i < n; i++){
        B[i] = (A[i].first + 1) / 2;
        m -= B[i];
    }
    if(m<0){
        cout << -1 << endl;
        return;
    }
    int x = min(m,A.back().first - B.back());
    B.back() += x; m -= x;
    for(int i = n - 2; i >= 0; i--){
        x = min(m, min(B[i+1],A[i].first) - B[i]);
        m -= x; B[i] += x;
    }
    if(m>0){
        cout << -1 << endl;
        return;
    }
    vi ret(n);
    for(int i = 0; i < n; i++) ret[A[i].second] = B[i];
    for(int i = 0; i < n; i++) cout << ret[i] << ' ';
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("Local.in","r",stdin);
    freopen("ans.out","w",stdout);
    #endif
    solve();
    return 0;
}

//
// CODED by HARRY on 22/10/2020
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define charToInt(c) (c-'0')

const ll int inf = 2e5 + 5;
const ll int MOD = 1e9 + 7;
const int MAX = 2e5 + 2;

using namespace std;

void solve() {
    int n, w;
    cin >> n >> w;
    vector<pair<int, int>> a(n);
    int halfSum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
        halfSum += (a[i].first + 1)/ 2;
    }
    if(halfSum > w){
        cout << -1 << endl;
        return;
    }
    sort(a.begin(), a.end());
    vector<pair<int, int>> res(n);
    for (int i = 0; i < n; ++i) {
        res[i].first = a[i].second;
        res[i].second = (a[i].first + 1) / 2;
    }
    w -= halfSum;
    int i = n - 1;
    while(w > 0 and i >= 0){
        if(a[i].first - res[i].second <= w){
            w -= (a[i].first - res[i].second);
            res[i].second = a[i].first;
        }else{
            res[i].second += w;
            break;
        }
        i--;
    }
    sort(res.begin(), res.end());
    for (i = 0; i < n; ++i) {
        cout << res[i].second << " ";
    }
}

int main(){
    /*int tc;
    cin >> tc;
    while(tc--)
        solve();
    */solve();
    return 0;
}

#include<cstdio>
#include<algorithm>
int n,w,a[107],b[107];
int main()
{
    scanf("%d%d",&n,&w);
    for(int i=1; i<=n; ++i)scanf("%d",a+i),w-=b[i]=a[i]+1>>1;
    if(w<0)return puts("-1"),0;
    while(w)
    {
        int mw=0;
        for(int i=1; i<=n; ++i)if((!mw||a[i]>=a[mw])&&a[i]>b[i])mw=i;
        int x=std::min(a[mw]-b[mw],w);
        b[mw]+=x;
        w-=x;
    }
    for(int i=1; i<=n; ++i)printf("%d ",b[i]);
    return 0;
}

/*			Arjun Sanjeev
			IIIT-Hyderabad

	********************************************
	*	"Never regret anything in life.	   *
	*	 If it's good, it's wonderful.	   *
	*	 If it's bad, it's experience."    *
	********************************************	*/

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define let(x,a) __typeof(a) x(a)
#define all(a) (a).begin(),(a).end()
#define endl '\n'
#define present(c,x) ((c).find(x) != (c).end())
#define tr(v,it) for(let(it,v.begin()); it != v.end(); it++)
#define rtr(v,it) for(let(it,v.rbegin()); it != v.rend(); it++)

#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#define LL long long int
#define PII pair<int,int>
#define VI vector<int>
#define inf INT_MAX

using namespace std;

bool cmp(PII a, PII b)
{
	return a.s<b.s;
}

int main()
{
	ios::sync_with_stdio(false);
	int n,tot;
	cin>>n>>tot;
	vector<PII> v(n,PII());
	VI ans(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>v[i].f;
		v[i].s=i;
	}
	sort(all(v));
	for(int i=0;i<n;i++)
	{
		ans[v[i].s]=(v[i].f+1)/2;
		tot-=ans[v[i].s];
		if(tot<0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		int x=v[i].f-ans[v[i].s];
		ans[v[i].s]+=min(tot,x);
		tot-=min(tot,x);
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

int main(){
    vector <float> result;
    vector <float> vol;
    pair <int,int> p;
    priority_queue < pair<int,int> > pq;
    float n,x,w,n_i, minVol,answ;
    cin >> n >>w;
    result.clear();
    vol.clear();
    for(int i = 0; i<n;i++){
		  cin >> n_i;
		  //cout << "n_i/2 = " << n_i/2 << endl;
		  minVol = ceil(n_i/2);
		 // cout << "minVol = " << minVol << endl;
		  result.push_back(minVol);
		  pq.push(make_pair(n_i,i)); //pair = (volume, index)
		  w-= minVol;
		  if(w<0){
		      cout << -1 << endl;
		      return 0;
		  }
		}
		while(!pq.empty() && w>0){
    	p = pq.top();
    	//cout << "p.first = " << p.first <<  " p.second = " << p.second << endl;
    	pq.pop();
    	if(w+result[p.second] <= p.first){
    		result[p.second]+=w;
    		w=0; // 0 + result[i] always will be less then its volume
    		break;
    	}else{
    		w-= p.first - result[p.second];
    		result[p.second] = p.first;
    		if(w<0){
		      cout << -1 << endl;
		      return 0;
    		}
    	}
    }
    if(w!=0){
			cout << -1 << endl;
			return 0;
    }else{
    	cout << result[0];
    	for(int i = 1; i<n;i++){
    		cout << " " << result[i];
    	}
    	cout << endl;
    }

return 0;
}
// 1495424520703

#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define fr first
#define sc second
#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
// taskkill /im new.exe /t /f
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 31) , mod = 998244353;
ll dp[3005][3005][3] , s[3001] , p[3001];
ll dpf(ll i , ll j , ll c , ll n){
  if(c==3){
    return 0;
  }
  if(i==n+1) return 3e8+5;
  ll &ans = dp[i][j][c];
  if(ans!=-1) return ans;
  ans = dpf(i+1,j,c,n);
  if(s[i]>s[j]) ans = min(ans,p[i]+dpf(i+1,i,c+1,n));
  return ans;
}
ll mult(ll a , ll b ){
  ll ans = 1;
  while(b){
    if(b%2) ans = (ans*a)%mod;
    b = b/2;
    a = (a*a)%mod;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
   //freopen("error.txt", "w", stderr);
  freopen("output.txt", "w", stdout);
#endif

 ll T = 1 ;
//cin>>T;
for(ll t=0;t<T;t++)
{
  ll n , total_tea ;
  cin>>n>>total_tea;
  ll tc = 0 , tr = 0;
  vector <pair <ll , ll>> f , pos;
  for(ll i=1;i<=n;i++){
    ll a;
    cin>>a;
    tr = tr + (a+1)/2;
    tc = tc + a;
    f.pb({(a+1)/2,a});
    pos.pb({a,i-1});
  }
  //for(auto x:f) cout<<x.fr<<" "<<x.sc<<endl;
  if(total_tea<tr||total_tea>tc){
    cout<<-1<<endl;
    return 0;
  }
  sort(pos.begin(),pos.end(),greater<>());
  vector <ll> ans(n,'0');
  for(ll i=0;i<n;i++){
    ans[pos[i].sc] = f[pos[i].sc].fr;
    total_tea = total_tea - f[pos[i].sc].fr;
  }
  if(total_tea){
    //cout<<total_tea<<endl;
    for(ll i=0;i<n&&total_tea;i++){
      ll dif = f[pos[i].sc].sc - f[pos[i].sc].fr;
      if(dif>total_tea)
        dif = total_tea;
      total_tea = total_tea - dif;
      ans[pos[i].sc] = ans[pos[i].sc] + dif;
    }
  }
  for(auto x:ans) cout<<x<<" ";
}
  return 0;
}

#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long int LLI;

#define _ ios_base::sync_with_stdio(0);
#define debug

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

int a[105];
int b[105];
int c[105];
vector<pair<int, int> > v;

int main() { _
    int n, w;
    while (cin >> n >> w) {
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            v.push_back(make_pair(a[i], i));
        }
        sort(v.rbegin(), v.rend());
        for (int i = 0; i < n; ++i) {
            a[i] = v[i].first;
            c[v[i].second] = i;
        }
        int used = 0;
        for (int i = 0; i < n; ++i) {
            b[i] = (a[i]+1)/2;
            used += b[i];
        }

        int tmp = 105;
        while (tmp--) {
            for (int i = 1; i < n && used < w; ++i) {
                if (b[i] > b[i-1]) {
                    for (int j = i-1; j >= 0; --j) {
                        if (b[j] < b[j+1]) {
                            if (a[j] < b[j+1]) {
                                used = 10000005;
                            } else {
                                used += b[j+1] - b[j];
                                b[j] = b[j+1];
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < n && used < w; ++i) {
                while (a[i] > b[i]) {
                    if (used == w) break;
                    if (i && b[i] == b[i-1]) break;
                    b[i]++;
                    used++;
                }
            }
        }

        if (used != w) cout << "-1\n";
        else {
            int sum = 0;
            for (int i = 0; i < n; ++i) sum += b[i];
            assert(sum == w);
            for (int i = 0; i < n; ++i) assert(b[i]*2 >= a[i]);
            for (int i = 0; i < n; ++i) cout << b[c[i]] << " ";
            cout << "\n";
        }
        v.clear();
    }

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;

    int n,w;cin>>n>>w;
    vector<int> a(n),ans(n);
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans[i]=ceil(a[i]*1.0/2);
        v[i]={a[i],i};
        w-=ans[i];
    }
    sort(v.rbegin(),v.rend());
    if(w<0){
        cout<<-1;
    }
    else{
        for(auto x:v){
            if(w>a[x.second]/2){
                ans[x.second]=a[x.second];
                w-=a[x.second]/2;
            }
            else {
                ans[x.second]+=w;
                w=0;
                break;
            }
        }
        if(w){
            cout<<-1;
        }
        else {
            for(auto x:ans){
                cout<<x<<" ";
            }
        }
    }

    #ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif
    return 0;
}

#include <iostream>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;

/// Greedy
struct TeaCup{
	int dt,c,vt;
};
bool ss(TeaCup a,TeaCup b){
	return a.dt>b.dt;
}

int main() {
	int n,w;
	cin>>n>>w;
	int a[n+1];
	TeaCup b[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	int s = 0;
	for(int i=1;i<=n;i++){
		s+= ceil(a[i] * 1.0 /2);
		b[i].c= ceil(a[i] * 1.0 /2);
		b[i].dt = a[i];
		b[i].vt=i;
	}

	sort(b+1,b+n+1,ss);
	for(int i=1;i<=n;i++){
		while(s<w && b[i].c<b[i].dt){
			s++;
			b[i].c++;
		}
		a[b[i].vt] = b[i].c;
	}

	if(s==w){
		for(int i=1;i<=n;i++) cout<<a[i]<<" ";
	}else cout<<"-1";
	return 0;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x;
	int idx;
};
node a[1001],b[1001];

bool cmp(node a,node b)
{
	return a.x > b.x;
}
bool cmpf(node a,node b)
{
	return a.idx < b.idx;
}
int main()
{
	int n,w;
	int count=0,sum=0;
	cin >>  n >> w;
	for(int i=0;i<n;i++)
	{
		cin >> a[i].x;
		count+=a[i].x;
		a[i].idx=i;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if((a[i].x)%2==0)
			b[i].x=a[i].x/2;
		else
			b[i].x=a[i].x/2+1;
		sum+=b[i].x;
		b[i].idx=a[i].idx;
	}
	int k=w;
	w=w-sum;
//	cout << w << endl;
	if(w<0 || count < k)
	{
		cout << "-1" << endl;
	}
	else
	{
		int i=0;
		while(w)
		{
			if(b[i].x<a[i].x)
			{
				b[i].x=b[i].x+1;
				w--;
			}
			i++;
			if(i==n)
				i=0;
		}
		sort(b,b+n,cmpf);
		for(int i=0;i<n;i++)
			cout << b[i].x << " ";
	}
	return 0;
}

#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int n, w;
struct data{
	int first, second;
}a[105];
int rs[105];
int sum;
bool cmp(data x, data y)
{
	return x.first > y.first;
}
bool resort(data x, data y)
{
	return x.second < y.second;
}
int main()
{
	cin >> n >> w;
	int s = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		a[i].first = t;
		a[i].second = i;
		if (t % 2) sum += t / 2 + 1;
		else sum += t / 2;
		s += a[i].first;
	}
	sort(a,a + n,cmp);
	if (w > s) { cout << -1; return 0; }
	if (sum > w) { cout << -1; return 0; }
	else
	{
		int t = w - sum;
		for (int i = 0; i < n; i++)
		{
			int temp = a[i].first / 2;
			a[i].first%2 ? temp++ : 0;
			if (t)
			{
				if (t > a[i].first - temp)
					t -= a[i].first - temp;
				else
					a[i].first = temp + t,t=0;
			}
			else a[i].first = temp;
		}
	}
	sort(a, a + n, resort);
	for (int i = 0; i < n; i++)
		cout << a[i].first<<" ";
}

#define _CRT_SECURE_NO_WARNINGS
//#include<bits\stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int A[101];
int A1[101];
pair<int, int> A2[101];
char dic[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
int main() {
/*#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif*/
		int n, tea;
		cin >> n >> tea;
		for (int i = 0; i< n; i++) {
			cin >> A[i];
		}
		for (int i = 0; i < n; i++) {
			A2[i].first = A[i];
			A2[i].second = i;
		}
		sort(A2, A2 + n);

		for (int i = 0; i< n; i++) {
			A2[i].first = A2[i].first / 2;
			tea -= A2[i].first;
			if (A[A2[i].second] % 2 == 1) {
				A2[i].first++;
				tea--;
			}
		}

		if (tea < 0) { cout << -1 << endl; return 0; }
		int i = n - 1;
		while (tea) {
			if (i >= n) { cout << -1 << endl; return 0; }
			if (A2[i].first == A[A2[i].second]) i--;
			else {
				A2[i].first++;
				tea--;
			}
		}
		for (int i = 0; i< n; i++) {
			A1[A2[i].second] = A2[i].first;
		}
		for (int i = 0; i< n; i++) {
			cout << A1[i];
			if (i == n - 1) cout << endl;
			else cout << " ";
		}
		return 0;
	}

#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int a,b,c;
};
int cmp(node x,node y)
{
    return x.a>y.a;
}
int cmp2(node x,node y)
{
    return x.b<y.b;
}
int main()
{
    int n,w,i,j,sum=0;
    struct node x[200],t;
    scanf("%d%d",&n,&w);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&x[i].a);
        if(x[i].a%2==0)
            x[i].c=x[i].a/2;
        else
            x[i].c=x[i].a/2+1;
        sum+=x[i].c;
        x[i].b=i;
    }
    if(sum>w)
        puts("-1");
    else
    {
        sort(x+1,x+n+1,cmp);
        w=w-sum;
        i=1;
        while(w)
        {
            if(w>(x[i].a-x[i].c))
            {
                w=w-(x[i].a-x[i].c);
                x[i].c=x[i].a;
            }
            else
            {
                x[i].c=x[i].c+w;
                w=0;
            }
            i++;
        }
        sort(x+1,x+n+1,cmp2);
        for(i=1; i<=n; i++)
        {
            printf("%d",x[i].c);
            if(i!=n)
                printf(" ");
        }
        puts("");
    }
    return 0;
}
/*2018-07-23 15:18:41.973*/

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;

const int mx=105;

struct node{
    int v;
    int c;
    int id;
}cup[mx];

bool cmp1(node a,node b)
{
    return a.v>b.v;
}

bool cmp2(node a,node b)
{
    return a.id<b.id;
}

int main()
{
    int n,i,w,v;
    scanf("%d%d",&n,&w);
    for(i=0;i<n;i++)
    {
        scanf("%d",&v);
        cup[i].id=i;
        cup[i].v=v;
        cup[i].c=0;
    }
    for(i=0;i<n;i++)
    {
        cup[i].c+=(cup[i].v+1)/2;
        w-=(cup[i].v+1)/2;
        if(w<0)
        {
            printf("-1\n");
            return 0;
        }
    }
    sort(cup,cup+n,cmp1);
    for(i=0;i<n;i++)
    {
        if(w>=(cup[i].v-cup[i].c))
        {
            w-=(cup[i].v-cup[i].c);
            cup[i].c=cup[i].v;
        }
        else
        {
            cup[i].c+=w;
            break;
        }
    }
    sort(cup,cup+n,cmp2);
    for(i=0;i<n;i++)
    {
        printf("%d",cup[i].c);
        if(i==n-1) puts("");
        else printf(" ");
    }
}
/*2018-07-21 21:28:00.792*/

#include<bits/stdc++.h>
using namespace std;
long long n,w,a[1000],c[1000],t=0,s=0;
pair <long long ,long long> p[1000];
main()
{
	cin>>n>>w;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		c[i]=(a[i]+1)/2;
		s+=(a[i]+1)/2;
	}
	if(w<s) {
	cout<<-1<<endl;
	return 0;
	}
	for(int i=1; i<=n; i++)
	{
		p[i].first=a[i];
		p[i].second=i;
	}
	sort(p+1,p+n+1);
	s=w-s;
	for(int i=n; i>=1; i--)
	{
		c[p[i].second]+=min(s,a[p[i].second]/2);
		s-=min(s,a[p[i].second]/2);
	}
	for(int i=1; i<=n; i++)
		cout<<c[i]<<" ";
}

#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}
main()
{
    int n,nn,sum=0;
    cin >> n >> nn;
    pair <int,int> arr[n];
    for(int i=0;i<n;i++)
    {
        arr[i].second=i+1;
    scanf("%d",&arr[i].first);
    if(arr[i].first%2==1)
    sum+=arr[i].first/2+1;
    else
    sum+=arr[i].first/2;
    }
    int x=nn-sum;
    if(x<0)
    {
        cout << "-1";
        return 0;
    }
    sort(arr,arr+n);
    for(int i=n-1;i>=0;i--)
    {
        if(x>0)
        {

            if(x>=arr[i].first/2+1 && arr[i].first%2==1)
                {
                    x-=arr[i].first/2;
                }
            else if(x>=arr[i].first/2 && arr[i].first%2==0)
                {
                    x-=arr[i].first/2;
                }
            else
            {
                             if(arr[i].first%2==1)
                                arr[i].first++;
                            arr[i].first=arr[i].first/2+x;

                x=0;
            }
        }
        else
        {
           if(arr[i].first%2==1)
                    arr[i].first++;
           arr[i].first/=2;
        }
    }
    sort(arr, arr+n, sortbysec);
for(int i=0;i<n;i++)
{
    cout << arr[i].first << " ";
}

}

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

#define N 101
typedef pair<int, int> ii;

ii a[N];
int b[N];

int main(){

    int n,w;
    cin>>n>>w;

    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }

    int sum=0;

    for(int i=0;i<n;i++)
        sum+=(a[i].first+1)/2;

    if(sum>w){
        cout<<-1;
        return 0;
    }

    for(int i=0;i<n;i++)
        b[i]=(a[i].first+1)/2;

    sort(a, a+n, greater<ii>());

    w-=sum;

    for(int i=0;i<n && w;i++){
        if(w<=a[i].first-b[a[i].second]){
            b[a[i].second]+=w;
            w=0;
        }else{
            w-=a[i].first-b[a[i].second];
            b[a[i].second]=a[i].first;
        }
    }

    for(int i=0;i<n;i++)
        cout<<b[i]<<" ";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,w,arr[102],x,ar[102];
    while(scanf("%d %d",&n,&w)==2)
    {
        int ans =0,chk=0;
        vector< pair<int,int> > cup;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&x);
            chk += x;
            ans += ceil(x/2.0);
            arr[i]=ceil(x/2.0);
            cup.push_back(make_pair(x,i));
        }
        //cout<<endl<<ans<<endl;
        if(ans>w || chk<w)
        {
            printf("-1\n");
        }
        else
        {
            w=w-ans;
            sort(cup.begin(),cup.end());
            //int sum=0;
            for(i=cup.size()-1;i>=0;i--)
            {
                if((cup[i].first-arr[cup[i].second]) <=w)
                {
                    w=w-(cup[i].first-arr[cup[i].second]);
                    arr[cup[i].second]=cup[i].first;
                }
                else if((cup[i].first-arr[cup[i].second]) >w)
                {
                    arr[cup[i].second] +=w;
                    w=0;
                    break;
                }
            }
            for(i=1;i<=n;i++)
            {
                printf("%d",arr[i]);
                if(i==n)
                    cout<<endl;
                else cout<<" ";
            }
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod1 1000000007
int main()
{
    vector< pair<ll,ll> > v;
    vector<ll> s;
    ll n,w,ans=0,sum=0,z;
    double x,y;
    cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>z;
        v.push_back(make_pair(z,i));
        sum+=z;
        x=z;
        x=ceil(x/2);
        ans+=x;
        s.push_back(x);
    }
    if(w<ans || w>sum) cout<<"-1";
    else{
        z=w-ans;
        sort(v.begin(),v.end());
        for(ll i=n-1;i>=0;i--)
        {
            y=v[i].first;
            x=ceil(y/2);
            //cout<<z<<endl;
            if(z>=y-x)
            {
                z-=y-x;
                s[v[i].second]=y;
            }
            else
            {
                s[v[i].second]+=z;
                z=0;
                break;
            }
        }
        for(ll i=0;i<n;i++)
            cout<<s[i]<<" ";
    }
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct obj {
	int id;
	int volume;
	int currVolume;
};

bool compare1(obj q, obj k) {
	return q.volume > k.volume;
}

bool compare2(obj q, obj k) {
	return q.id < k.id;
}

int main() {
	int n, w;
	cin >> n >> w;
	vector<obj> v1(n);

	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> v1[i].volume;
		v1[i].id = i;
		int num;
		if (v1[i].volume % 2 == 1) {
			num = v1[i].volume / 2 + 1;
		}
		else {
			num = v1[i].volume / 2;
		}
		total += num;
		v1[i].currVolume = num;
	}

	if (w < total) {
		cout << -1 << endl;
		return 0;
	}
	else if (w == total) {
		for (int i = 0; i < n; i++) {
			cout << v1[i].currVolume << " ";
		}
		return 0;
	}
	else {
		w -= total;
		// sort according to volume from largest to smallest
		sort(v1.begin(), v1.end(), compare1);
		for (int i = 0; i < n; i++) {
			if (v1[i].volume - v1[i].currVolume <= w) {
				w = w - v1[i].volume + v1[i].currVolume;
				v1[i].currVolume = v1[i].volume;

			}
			else {
				v1[i].currVolume += w;
				w = 0;
				break;
			}
		}
		// sort according to id which is the original form
		sort(v1.begin(), v1.end(), compare2);
		for (int i = 0; i < n; i++) {
			cout << v1[i].currVolume << " ";
		}
	}

	return 0;
}

#include<iostream>
using namespace std;
int n,w,a[105],b[105],r;
bool danhdau[105];
int main(){
	cin>>n>>w;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=(a[i]+1)/2;
		w=w-b[i];
	}
	if(w<0){
		cout<<"-1";
		return 0;
	}
	while(w>0){
		int max=-1;
		for(int i=0;i<n;i++){
			if(a[i]>max&&a[i]!=b[i]){
				max=a[i];
				r=i;
			}
		}
		if(max!=-1){
			b[r]++;
			w--;
		}
		else break;
	}
	for(int i=0;i<n;i++){
		cout<<b[i]<<" ";
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
using namespace std;
const int N = 100100;
struct node
{
    int v;
    int p;
    int ans;

};
int cmp1(const node &a,const node &b)
{
    return a.v<b.v;
}
int cmp2(const node &a,const node &b)
{
    return a.p<b.p;
}

node a[N];
int n,w;
int main()
{

    scanf("%d%d",&n,&w);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i].v);
        a[i].p=i;
    }
    sort(a+1,a+n+1,cmp1);
    for (int i=1;i<=n;++i)
    {
        a[i].ans=ceil(a[i].v*1.0/2);
      //  printf("%d %d\n",a[i].ans,a[i-1].ans);
        if (a[i].v>a[i-1].v&&a[i].ans==a[i-1].ans)
        {
            a[i].ans++;
        }
    }
    int sum=0;
    for (int i=1;i<=n;++i)
    {
        sum+=a[i].ans;
    }
    if (sum>w)
    {
        printf("-1\n");
        return 0;
    }
    w-=sum;
    for (int i=n;i>=1;--i)
    {
        a[i].ans+=w;
        w=0;
        if (a[i].ans>a[i].v)
        {
            w+=a[i].ans-a[i].v;
            a[i].ans=a[i].v;
        }
    }
    sort(a+1,a+n+1,cmp2);
    for (int i=1;i<=n;++i)
    {
        if (i>1)
        {
            printf(" ");
        }
        printf("%d",a[i].ans);
    }

    return 0;
}
/*2018-07-21 20:24:16.362*/

// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = 0x3f3f3f3f;
int knight_moves[8][2]={{-2,-1},{-1,-2},{1,-2},{2,-1},{-2,1},{-1,2},{1,2},{2,1}};
int moves[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	#ifndef ONLINE_JUDGE
	freopen("inputf.in","r",stdin);
	freopen("outputf.in","w",stdout);
	#endif

	int n,w;
	cin>>n>>w;
	vector<pii>v(n);
	int total=0;
	for(int i=0;i<n;i++)
	{
		cin>>v[i].first;
		v[i].second=i;
		total+=v[i].first;
	}
	sort(v.begin(),v.end());
	if(w<(total+1)/2)
		cout<<-1;
	else
	{
		vector<int>ans(n);
		ans[0]=(v[0].first+1)/2;
		w-=(v[0].first+1)/2;
		for(int i=1;i<n;i++)
		{
			if(v[i].first==v[i-1].first)
			{
				ans[i]=ans[i-1];
				w-=ans[i];
			}
			else
			{
				ans[i]=max(ans[i-1]+1,(v[i].first+1)/2);
				w-=ans[i];
			}
		}
	// 	for(int i=0;i<n;i++)
	// 	cout<<ans[i]<<" ";
	// cout<<endl;
		if(w)
		{
			int j=n-1;
			while(w>0)
			{
				if(ans[j]==v[j].first)
				{
					j--;
					if(j<0)
					j=n-1;
				}
				else
				{
					ans[j]++;
					w--;
					j--;
				if(j<0)
					j=n-1;
			}
			}
		}
		vector<int>final(n);
		for(int i=0;i<n;i++)
		{
			final[v[i].second]=ans[i];
		}
		for(int i=0;i<n;i++)
			cout<<final[i]<<" ";
	}

}

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

// to sort in descending order
bool sortinrev(const pair<int,int>&a, const pair<int,int>&b){
    return (a.first > b.first);
}

// to get minimum of tea left and size of tea pot
int min(int a, int b){
    return a<b?a:b;
}

int main(){
    int n,w;
    std::cin>>n;
    std::cin>>w;

    int teaSize[n];
    int index[n],value[n];

    // index for vector pair
    for(int i=0;i<n;i++)
        index[i]=i;

    for(int i=0;i<n;i++){
        std::cin>>teaSize[i];
        value[i]=teaSize[i];    // for vector pair to sort
        w = w-((teaSize[i]+1)/2);   //distributing at least half
        teaSize[i] = ((teaSize[i]+1)/2);    // putting in capacity left
    }

    if(w<0){
        std::cout<<"-1";
        return 0;
    }
    else{
        std::vector< pair<int,int> > vect;
        for(int i=0;i<n;i++)
            vect.push_back( make_pair(value[i],index[i]));  // orignal sizes and their corresponding indices

        std::sort(vect.begin(),vect.end(),sortinrev);   // sorted according to size

        int i = 0,j=1;

        while(w>0 && i<n){
            j=1;
            while((i+j)<n && vect[i+j].first == vect[i].first)
                j++;

            int temp = min((int)(vect[i].first/2)*j,w);    // getting minimum of tea left and capacity

//            std::cout<<"j temp"<<j<<"\t"<<temp<<"\n";

            w = w - temp;
            temp = temp/j;

            j--;
            i=i+j;

            while(j>=0){
                teaSize[vect[i-j].second]+=temp;
                j--;
            }
  //          std::cout<<i<<"\t"<<teaSize[i]<<"\n";
            i++;
        }

        for(i=0;i<n;i++){
            std::cout<<teaSize[i]<<" ";
        }
    }
    return 0;

}

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()

using namespace std;

void read ()
{
}

void solve ()
{
    long long n, w;
    int a[12312];
    int b[12312];

    cin >> n >> w;

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

    for (int i = 0; i < n; i++)
    {
        int now = ceil((long double)(a[i]) / 2.0);

        if (w < now)
        {
            cout << -1;
            return;
        }

        w -= now;
        b[i] = now;
    }

    int ind = 0;

    for (int k = 0; k < n; k++)
    {
        int ind = 0;

        for (int i = 0; i < n; i++)
        {
            if (a[i] > a[ind] && b[i] < a[i])
                ind = i;
        }

        while (w > 0 && b[ind] < a[ind])
        {
            b[ind]++;
            w--;
        }
    }

    if (w > 0)
    {
        cout << -1;
        return ;
    }

    for (int i = 0; i < n; i++)
        cout << b[i] << " ";

}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie();
    cout.tie();
    ios_base::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n,w;
int x;
int sum=0;
cin>>n>>w;
vector<pair<int,int>>v;
for(int i=0;i<n;i++)
{
	cin>>x;
	v.push_back(make_pair(x,ceil((x*1.0)/2)));
	sum+=ceil(x*1.0/2);

}
if(sum>w)
	cout<<-1<<endl;

else
{
vector<pair<int,int>>v1=v;
w=w-sum;

sort(v.begin(),v.end());

while (w>0)
{
for(int i=n-1;i>=0;i--)
if(w>0)
{
	v[i].second++;
	w--;

}
}

vector<pair<int,int>>v2;
for(int i=0;i<v1.size();i++)
{
	for(int j=0;j<v.size();j++)
	{
		if(v1[i].first==v[j].first)
		{
			v2.push_back(v[j]);
			v.erase(v.begin()+j);
			break;

		}

	}

}

	for(int i=0;i<v2.size();i++)
		cout<<v2[i].second<<" ";

cout<<endl;

}

//system("pause");
	return 0;
}

# include <bits/stdc++.h>
#define ll long long
using namespace std;
 pair< ll , ll> a[10101];
 pair< ll , ll> d[10101];
    ll q[101101];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n , i  , w , s=0;
    cin>>n>>w;
    for(i=1;i<=n;i++)
    {
        cin>>a[i].first;
        a[i].second=i;
        s+=(a[i].first/2+a[i].first%2);
        d[i].first=a[i].first/2+a[i].first%2;
        d[i].second=i;
        a[i].first=a[i].first-(a[i].first/2+a[i].first%2);
    }
    sort(a+1,a+1+n);
    sort(d+1,d+1+n);
    if(s>w) {cout<<-1;return 0;}
    else
        w-=s;
        i=n;
    while( w>0 && i>0 )
    {
        if(w<=a[i].first)
        d[i].first+=w;
        else
        d[i].first+=a[i].first;
        w-=a[i].first;
    }
    for(i=1;i<=n;i++)
        swap(d[i].first,d[i].second);
    sort(d+1,d+1+n);
    for(i=n;i>1;i--)
    if(d[i].second<d[i-1].second)
    {cout<<-1;return 0;}
    for(i=n;i>=1;i--)

        cout<<d[i].second<<' ';
return 0;
}

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
struct c
{
    int a;
    int pos;
}data[110];
int cmp1(int a,int b)
{
    return a>b;
}
int cmp2(c h,c j)
{
    return h.a>j.a;
}
int cmp3(c h,c j)
{
    return h.pos<j.pos;
}
int main()
{
    int b[110];
    int n,w;
    scanf("%d%d",&n,&w);
    for (int i=1;i<=n;i++)
    {scanf("%d",&data[i].a);b[i]=data[i].a;data[i].pos=i;}
    int temp1=0;
    for(int i=1;i<=n;i++)
        temp1+=data[i].a;
    int temp=0;
    sort(data+1,data+1+n,cmp2);
    sort(b+1,b+1+n,cmp1);
    for (int i=1;i<=n;i++)
    {
        if(data[i].a%2==0)
            data[i].a/=2;
        else
            data[i].a=data[i].a/2+1;
    }
    for(int i=1;i<=n;i++)
        temp+=data[i].a;
    if(temp>w)
        cout << -1;
    else if (temp1<w)
        cout << -1;
    else
    {
        int i=1;
        int rest=w-temp;
        while(rest>0)
        {
            if(b[i]-data[i].a<=rest)
            {data[i].a=b[i];rest-=b[i]-data[i].a;i++;}
            else
            {data[i].a+=rest;rest=0;}
        }
        sort(data+1,data+1+n,cmp3);
        for (int i=1;i<=n;i++)
            cout << data[i].a << ' ';
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int n=110;
int a[110];
int main(){
    int n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)cin>>a[i];
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=(a[i]/2)+(a[i]%2);
    }
    if(sum>w)cout<<-1<<endl;
    else{
        int dif=w-sum;
        int v=dif;
        //cout<<v<<endl;
        dif/=n;
        dif++;
        for(int i=1;i<=n;i++){
            int  val=a[i]/2+(a[i]%2);
            if(v==0){
                cout<<val<<' ';
            }
            else{
                if(v<dif){
                    cout<<a[i]+v;
                    v=0;
                }
                else if(val+dif<=a[i]){
                    v-=dif;
                    cout<<dif+val<<' ';
                }
                else{
                    cout<<a[i]<<' ';
                    v-=(a[i]-val);
                }
            }

        }
    }
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, w;

    cin >> n >> w;

    vector < pair<int, int> > vec;
    vector < int > ans(n, 0), check(n, 0);

    for(int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        vec.push_back({x, i});
    }

    sort(vec.rbegin(), vec.rend());

    for(int i=0; i<n; i++)
    {
        int half = ceil((double)vec[i].first / 2.0);
        //cout << half << " "<< w << endl;

        if(!w)
        {
            cout << -1 << endl;
            return 0;
        }
        w -= half;

        ans[vec[i].second] += half;
        check[vec[i].second] += half;
    }

    for(int i=0; i<n && w; i++)
    {
        int x = vec[i].first;
        int j = vec[i].second, h = w - x;
        //cout << h << " " <<  w <<  " " << x << endl;

        if(h <= 0)
        {
            ans[j] += w;
            check[j] += w;
            w = 0;
            break;
        }

        w -= x;
        ans[j] += h;
        check[j] += h;
    }

    sort(ans.rbegin(), ans.rend());

    if(ans != check || w)
    {
        cout << -1 << endl;
        return 0;
    }

    for(int i=0; i<n; i++)
    {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
#define OK          pf("YES\n")
#define _OK         pf("NO\n")
#define all(v)      v.begin(), v.end()
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k;
    cin>>n>>k;
    ll ar[n];
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    vector<ll>v;
    bool f=true;
    for(i=n-1; i>=0; i--)
    {
        ll r=ar[i]/2;
        if(ar[i]&1) r++;
        if(r>k)
        {
            f=false;
        }
        v.pb(r);
        k=k-r;
    }
    reverse(v.begin(),v.end());
    for(i=0; i<n; i++)
    {
        ll r=ar[i]-v[i];
        ll x=min(r,k);
        v[i]+=x;
        k=k-x;
    }
    if(k>0)f=false;
    if(f==false)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll ss=v.size();
    for(i=0; i<ss; i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
    return 0;
}
//https://github.com/me-shaon/bangla-programming-resources

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	int n,w,s=0;
	cin>>n>>w;
	vii a(n);
	vi ans(n);
	for(int i=0;i<n;++i){
		cin>>a[i].ff;
		s+=a[i].ff;
		a[i].ss=i;
	}
	for(int i=0;i<n;++i){
		ans[i] = (a[i].ff)/2;
		w-=(a[i].ff)/2;
	}
	if(w<0){
		cout<<-1<<endl;
		return;
	}
	sort(a.rbegin(),a.rend());
	int pos=0;
	while(w){
		if(ans[a[pos].ss] < a[pos].ff){
			ans[a[pos].ss]++;
			--w;
		}
		pos=(pos+1)%n;
	}
	for(int i=0;i<n;++i){
		if(ans[a[i].ss] < a[i].ff/2){
			cout<<-1<<endl;
			return;
		}
	}
	for(int i=0;i<n;++i){
		cout<<ans[i]<<" \n"[i==n-1];
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

#include <math.h>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#define inf 2000000000
#define MOD 1000000007
#define MAX 200005
#define M   10000007
typedef long long ll;
using namespace std;
const double eps=1e-12;
string s;
int n;
int k;
pair <int,int> a[MAX];
int ans[MAX];
int main (){
scanf("%d %d",&n,&k);
for(int i=0; i<n; i++){
    scanf("%d",&a[i].first);
    ans[i]=a[i].first/2;
    if(a[i].first&1){ans[i]++;}
    a[i].second=i;
    k-=ans[i];
}
if(k<0){printf("-1"); return 0;}
sort(a,a+n);
reverse(a,a+n);
for(int i=0; i<n&&k; i++){
int dif=abs(a[a[i].second].first-ans[i]);
ans[a[i].second]+=min(dif,k);
k-=min(k,dif);
}

for(int i=0; i<n; i++){
    printf("%d ",ans[i]);
}
return 0;
}

#include<bits/stdc++.h>

typedef long long int ll;

#define pp pair<ll,ll>
#define dbg printf("in");
#define NL printf("\n");

#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)

using namespace std;
int main() {
	int n, w, i,t; cin >> n >> w;
	long long arr[n];
	pair<int, int> temp[n];

	for (i = 0; i < n; i++) {
		cin >> t;
		temp[i] = { t,i };

		if (t % 2) {
			arr[i] = t / 2 + 1; w -= t / 2 + 1;
		}
		else {
			arr[i] = t / 2; w -= t / 2;
		}
	}

	if (w > 0) {
		long long x;

		sort(arr, arr + n);

		for (i = 1; i < n; i++) {
			if (arr[temp[i].second] < arr[temp[i - 1].second]) {
				x = arr[temp[i - 1].second] - arr[temp[i].second];

				if (w < x) {
					cout << -1 << endl; return 0;
				}

				w -= x;
				arr[temp[i].second] += x;
			}
		}

		i = n - 1;
		while (w && i >= 0) {
			x = temp[i].first - arr[temp[i].second];

			if (x < 0)
				i--;

			else {
				if (x < w) {
					arr[temp[i].second] += x; w -= x; i--;
				}

				else {
					arr[temp[i].second] += w; break;
				}
			}
		}

	}

	else if (w == 0) {
		for (int i = 0; i < n; i++)
			cout << arr[i] << " ";
		cout << endl;
		return 0;
	}

	else {
		cout << -1 << endl;
		return 0;
	}

	for (i = n -1; i >= 0; i--)
		cout << arr[i] << " ";

	cout << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector <int> v[108];
int b[100];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, w, sum = 0, ans = 0;
    cin >> n >> w;
    int a[n];
    for( int i = 0; i < n; ++i )
    {
        cin >> a[i];
        v[a[i]].push_back(i);
        sum = sum + a[i];
    }
    if( sum*1.0/2 > w ) cout << "-1";
    else
    {
        for( int i = 0; i < n; ++i )
        {
            int temp = ceil( a[i]*1.0/2 );
            b[i] = temp;
            w = w - temp;
        }
        for( int i = 107; i >= 0; --i )
        {
            if( w > 0 )
            {
                for( int j = 0; j < v[i].size(); ++j )
                {
                    int y = v[i][j];
                    while( b[y] < a[y] && w > 0 )
                    {
                        ++b[y];
                        --w;
                    }
                }
            }
        }
        for( int i = 0; i < n; ++i ) cout << b[i] << " ";
    }

}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define mod 1000000007
#define INF 10000000000000
#define mt make_tuple
#define g0 get<0>
#define g1 get<1>
#define g2 get<2>
#define out(x) cout<<x<<endl;
#define scan(x) cin>>x;

using namespace std;

 bool sortbysec(const pair<double,int> &a,const pair<double,int> &b)
{
    return (a.second < b.second);
}

bool sortbysectuple(const tuple<int, int, int>& a,const tuple<int, int, int>& b)
{
    return (get<1>(a) < get<1>(b));
}

bool sortbyth(const tuple<ll, ll, ll>& a,const tuple<ll, ll, ll>& b)
{
    return (get<2>(a) < get<2>(b));
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);auto hash2 = hash<T2>{}(p.second); return hash1 ^ hash2;
    }
};
ll modpow(ll x,ll y){

  if(y==0) return 1;
  ll u=modpow(x,y/2);
  u=(u*u)%mod;
  if(y%2==1) u=(u*x)%mod;
  return u;
}
ll solution(ll a,ll b,ll &x,ll &y){
  if(b==0){
    x=1;
    y=0;
    return a;
  }
  ll x1,y1;
  ll g=solution(b,a%b,x1,y1);
  x=y1;
  y=x1-y1*(a/b);
  return g;
  // x=x0+k*(b/g) y=y0-k*(a/g) all solutions
}

int main(){

       ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      //  priority_queue<int, vector<int>, greater<> > Q;
	   unordered_map<pair<int, int>, string, hash_pair> um,ba;

         ll n,t,x,sum=0,ma=0,ind=-1,i,prev;

         cin>>n>>t;
         vector<pair<ll,ll>>v;

         for(i=0;i<n;i++){
         cin>>x;
         v.pb(mp(x,i));
        }

         sort(v.begin(),v.end());

         int ans[n];

         memset(ans,0,sizeof(ans));

         prev=v[0].fi;
         ma=v[0].fi/2;
         if(v[0].fi%2!=0)
         ma++,sum+=ma;
         else
         sum+=ma;

         v[0].fi=ma;

         for(i=1;i<n;i++){

          x=v[i].fi;
          x/=2;
          if(v[i].fi%2!=0)
          x++;

          if(v[i].fi>prev && ma>=x)
          x=ma+1,ma=x;
          else
          ma=x;

          prev=v[i].fi;

          v[i].fi=x;
          sum+=v[i].fi;
        }

         if(t<sum){
         cout<<-1<<endl;
         return 0;
        }

          v[n-1].fi+=(t-sum);

          sort(v.begin(),v.end(),sortbysec);

          for(i=0;i<n;i++)

          cout<<v[i].fi<<" ";

          return 0;
}

#include <iostream>
#include <stdio.h>
using namespace std;

int a[110],avg[110]={0},b[110];
bool flag[110]={0};
int n,w,sum=0,res=0;
void fun(int i)
{
	if (w>0)
	{
		if (a[i]-b[i]>=w)
		{
			b[i]=b[i]+w;
			return;
		}

		else
		{
			if (a[i]-b[i]>0)
			{
				w=w-(a[i]-b[i]);
				b[i]=a[i];

			}
			fun(i+1);
		}
	}
}

int main()
{

	scanf ("%d%d",&n,&w);
	for (int i=0;i<n;i++)
	{
		scanf ("%d",&a[i]);
		if (a[i]%2!=0)
			b[i]=avg[i]=a[i]/2+1;
		else
			b[i]=avg[i]=a[i]/2;
		if (a[i]==0)	res++;
		sum=sum+avg[i];
	}

	if (sum>w)
	{
		printf ("-1\n");
		exit(0);
	}

	if (sum<w)
	{
		w-=sum;
		for (int i=n-res-1;i>-1;i--)
		{
			if (b[i]<=b[i+1])
			{
				b[i]=b[i+1]+1;
				w=w+avg[i]-b[i];
			}
		}
		if (w>0)
			fun(0);
	}
	for (int i=0;i<n;i++)
		printf ("%d ",b[i]);
	printf ("\n");
	return 0;
}

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

typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl

const ll INF = LLONG_MAX;
const ll  base = 1e9;
const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;

ll power(ll x, ll y){ ll res = 1;
    while (y > 0){  if (y & 1)  res = (res*x) ;  y = y>>1; x = (x*x);  }   return res; }

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n , w ; cin >> n >> w ;
    ll sum = 0 ;
    ll a[n] ;
    vector < long long > ans ;
    vector < pair < ll , ll >  >  store ;
    for (ll i=0 ; i<n; i++)  {
        cin >> a[i] ;
        store.push_back({a[i],i}) ;
        ll temp = (( a[i]&1 ) ? (a[i]/2 + 1) : a[i]/2 ) ;
        sum += temp ;
        ans.emplace_back ( temp ) ;
    }
    if (w >= sum)  {
        for (ll i = 0 ;i < n ; i++ )  store[i].first -= ans[i] ;
        sort (store.begin() , store.end()) ;
        ll rem = w - sum ;
        for ( ll i = n-1 ;i >= 0 ;i-- )  {
            if ( rem >= store[i].first ) ans[store[i].second] += store[i].first ;
            else
            {
                 ans[store[i].second] += rem ;
                 break ;
            }
        }
        for (auto el : ans ) cout << el << " " ;
    }else  cout << "-1"  ;

    cout << endl ;
    return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
bool sortbydes(const pair<int,int> &a,const pair<int,int> &b)
{
    return (b.first <= a.first);
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return(a.second < b.second);
}
int main() {
	int n,w,sum2 = 0;
	cin >> n;
	cin >> w;
	cout << endl;
	vector<pair<int,int>> vol;
	vector<pair<int,int>> vol2;
	int arr[n],arr2[n];
	for(int i = 0;i < n;i++)
	{
	    cin >> arr[i];
	    if(arr[i]%2==0)
	    arr2[i] = arr[i]/2;
	    if(arr[i]%2!=0)
	    arr2[i] = (arr[i]+1)/2;
	    vol.push_back(make_pair(arr[i],i+1));
	    vol2.push_back(make_pair(arr2[i],i+1));
	    sum2 = arr2[i]+sum2;
	}
	if(sum2 > w)
	{
	    cout << "-1" << endl;
	    return 0;
	}
	sort(vol.begin(),vol.end(),sortbydes);
	sort(vol2.begin(),vol2.end(),sortbydes);
	int j = 0;
	while(w- sum2 > 0 && j  <= n)
	{
	    if((vol[j].first - vol2[j].first) > (w - sum2))
	    {
	        vol2[j].first += (w-sum2);
	        sum2 = w;
	        j++;
	    }
	    else
	    {
	        sum2 += vol[j].first-vol2[j].first;
	        vol2[j].first = vol[j].first;
	        j++;
	    }
    }
	sort(vol2.begin(),vol2.end(),sortbysec);
	for(int i = 0;i < n;i++)
	{
	    cout << vol2[i].first << " ";
	}
	cout << endl;
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	long long sum=0,t, n,w;
	cin>>n>>w;
	bool b=0;
	vector<long long>v;
	while(n--){
	cin>>t;
	if(t%2==0)
	sum=sum+(t/2);
	else 	sum=sum+(t/2)+1;
	v.push_back (t);
	}
	long long def=w-sum;
	if(sum>w)
		cout<<"-1"<<endl;
	else{
		for(int i=0;i<v.size();i++){
			if(i==v.size()-1)
				b=1;
			if(def!=0){
			if(v[i]%2==0){

				if(def>=v[i]-v[i]/2)
				{
					if(b)
				cout<<v[i]<<endl;
					else
						cout<<v[i]<<" ";
				def=def-v[i]/2;
				}else{
					if(b)
			cout<<v[i]/2+def<<endl;
					else cout<<v[i]/2+def<<" ";
				def=0;

				}
				}
		else {

				if(def>=v[i]-(v[i]/2)+1)
				{if (b)
				cout<<v[i]<<endl;
				else cout<<v[i]<<" ";
				def=def-(v[i]-(v[i]/2+1));
				}else{
					if(b)
			cout<<(v[i]/2)+1+def<<endl;
					else cout<<(v[i]/2)+1+def<<" ";
				def=0;

				}

			}

			}else{

			if(v[i]%2==0)
				if(b)
	cout<<(v[i]/2)<<endl;
				else cout<<(v[i]/2)<<" ";
	else 	if (b) cout<<(v[i]/2)+1<<endl;
	else cout<<(v[i]/2)+1<<" ";
			}

	}
	}
//system("pause");
return 0;

}

#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
#define OK          pf("YES\n")
#define _OK         pf("NO\n")
#define all(v)      v.begin(), v.end()
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k;
    cin>>n>>k;
    ll ar[n];
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    vector<ll>v;
    bool f=true;
    for(i=n-1; i>=0; i--)
    {
        ll r=ar[i]/2;
        if(ar[i]&1) r++;
        if(r>k)
        {
            f=false;
        }
        v.pb(r);
        k=k-r;
    }
    reverse(v.begin(),v.end());
    for(i=0; i<n; i++)
    {
        ll r=ar[i]-v[i];
        if(k>=r){
            v[i]=ar[i];
            k=k-r;
        }
        else{
            v[i]+=k;
            k=0;
            break;
        }
    }
    if(k>0)f=false;
    if(f==false)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll ss=v.size();
    for(i=0; i<ss; i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
    return 0;
}
//https://github.com/me-shaon/bangla-programming-resources

#include <cstdio>
#include <algorithm>

int n, w, sum, cur, a[105], cap[105], ans[105];

struct A  {
	int x, id;
	A ( ) {	  }
	A ( int x, int id ) : x ( x ), id ( id ) {	   }
	inline short operator < ( const A& rhs )  const  {
		return x < rhs.x;
	}
} aa[105];

int main ( )  {
	scanf ( "%d%d", &n, &w );
	for ( int i = 1; i <= n; ++i )  scanf ( "%d", a + i );
	for ( int i = 1; i <= n; ++i )  sum += (a[i] + 1) >> 1;
	if ( sum > w )  {	puts ( "-1" ); return 0;   }
	for ( int i = 1; i <= n; ++i )	aa[i] = A ( a[i], i );
	std :: sort ( aa + 1, aa + 1 + n );
	for ( int i = n; i >= 1; --i )  {
		if ( w <= 0 )  {	puts ( "-1" ); return 0;   }
		cur = aa[i].id;
		ans[cur] = (aa[i].x + 1) >> 1;
		cap[cur] = a[cur] - ans[cur];
		w -= ans[cur];
	}
	if ( w > 0 )
		for ( int  i = n; w > 0 && i >= 1; --i )
			(w - cap[aa[i].id] >= 0) ? (ans[aa[i].id] = aa[i].x, w -= cap[aa[i].id]) : (ans[aa[i].id] += w, w = 0);
	if ( w )  {	puts ( "-1" ); return 0;   }
	for ( int i = 1; i <= n; ++i )  printf( "%d%c", ans[i], ( i == n ) ? 10 : 0 );
}

// Vaidik Patel(India)
// DA-IICT
#include <bits/stdc++.h>
using namespace std;
//********************************************
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//********************************************
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int INF = (int)1e9;
ll INFINF = (ll)1e18 + 10;
const ld PI = 3.14159265358979323846;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minheap priority_queue<ll,vector<ll>,greater<ll> >
#define maxheap priority_queue<ll,vector<ll>,less<ll> >
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rFOR(i,a,b) for(ll i=a;i>=b;i--)
#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

#define checkbit(n,b) ( (n >> b) & 1)//

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define M  1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define TIME cerr << "Time Elapsed : "<<1.0*clock()/CLOCKS_PER_SEC<<"\n";
#define lc 2*idx
#define rc 2*idx+1
ll powermodm(ll x,ll n,ll mod)
{ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%mod;x=(x*x)%mod;n=n/2;}return result;}
ll GCD(ll , ll );
ll LCM(ll ,ll);
ll power(int ,int);
ll choose(ll,ll);
int ones(ll);
void extendedEuclid(ll, ll);
ll MMI(ll, ll);
void fastscan(int &);
bool checkithbit(ll,ll); // ith bit is zero or not
vector<ll>SegmentTree;
void Build_Segment_Tree(vector<ll>&a,ll idx,ll l,ll r);
ll sum(ll idx,ll sl,ll sr,ll l,ll r);
void update(ll idx,ll sl,ll sr,ll value,ll id);
vector<ll>prime;
void findprime(void);
ll phi(ll num);
vector<int>isprime;
void precomputeprime(int N);
vector<int>prephi;
void precomputephi(int N);
//////////////////////////////////////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,w;
    cin>>n>>w;
    vector<ll>a(n);
    vector<pair<ll,ll>>b(n);
    ll temp=0;
    map<ll,ll>mp;
    FOR(i,0,n)
    {
        cin>>a[i];

        ll x=(ll)ceil(a[i]/(ld)2);
        b[i]={x,i};
        //cout<<x<<"\n";
        temp+=x;
        mp[a[i]]=i;
    }
    if(temp>w)
    {
        cout<<-1<<"\n";
        return 0;
    }
    sort(rall(b));
    ll rem=w-temp;
    FOR(i,0,n)
    {
        if(rem>0)
        {
            b[i].ff=b[i].ff+1;
            rem--;
        }
        a[b[i].ss]=b[i].ff;
    }
    FOR(i,0,n)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}
//////////////////////////////////////////////////////////////////////////
//precomputephi()
void precomputephi(int N)
{
    prephi.resize(N);

    FOR(i,0,N)
    {
        prephi[i]=i;
    }

    for(int i=1;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i;j<N;j+=i)
            {
                prephi[j]=prephi[j]-(prephi[j]/i);
            }
        }
    }
}

//precomputedprime()
void precomputeprime(int N)
{
    isprime.resize(N);
    isprime.assign(N,1);
    isprime[0]=0;
    isprime[1]=0;
    for(int i=2;i*i<=500005;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<=500005;j+=i)
            {
                isprime[j]=0;
            }
        }
    }
}
//"""euler totient function""": counts the number of integers between 1 and n inclusive, which are coprime to n.
ll phi(ll num) // find using factorization in O(sqrt(N)).....
{
    ll result=num;
    for(ll i=2;i*i<=num;i++)
    {
        if(num%i==0)
        {
            while(num%i==0)
            {
                num/=i;
            }
            result-=(result/i);
        }
    }
    if(num>1)
    {
        result-=(result/num);
    }
    return result;
}

void findprime(void)
{
    int N=1e6+5;
    vector<bool>isprime(N,1); //up to 1e6+5 number
    for(int i=2;i*i<=N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<=N;j+=i)
            {
                if(isprime[j])
                {
                    isprime[j]=0;
                }
            }
        }
    }

    for(int i=2;i<=N;i++)
    {
        if(isprime[i])
        {
            prime.pb(i);
        }
    }

}

bool checkithbit(ll a,ll i)
{
if(a & (1 << i))
{
return  true;
}
else
{
return false;
}
}
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a,ll b){return (max(a,b)/GCD(a,b))*min(a,b);}

ll power(int a , int n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x = x * x;
        n=n/2;
    }
    return result;
}
ll choose(ll n,ll k)
{
    if(k==0)  return 1;
    return (n* choose(n-1,k-1))/k;
}
int ones(ll n)
{
    int c=0;
    while(n)
    {
        n=n&(n-1);
        c++;
    }
    return c;
}
//store gcd of a,b in d
//store solution of a*x + b*y = d in x,y
// if gcd(a,b)=1 then x = a^(-1)(mod b) and y = b^(-1)(mod a)
ll d, x, y;
void extendedEuclid(ll A, ll B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// return modulo inverse of a wrt modulo p(should be prime)
// retunt -1 if modulo inverse does not exist
ll MMI(ll a, ll p)
{
    extendedEuclid(a,p);
    if(d==1 && p!=1)
        return ((x%p)+p)%p;
    else
        return -1;
}

//Fastest way to read Input
void fastscan(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
void Build_Segment_Tree(vector<ll>&a,ll idx,ll l,ll r) //where l and r is query range.
{
  if(l==r)
  {
    SegmentTree[idx]=a[l];
  }
  else
  {
    ll mid=(l+r)/2ll;
    Build_Segment_Tree(a,(2ll*idx),l,mid);
    Build_Segment_Tree(a,(2ll*idx)+1,mid+1,r);
    SegmentTree[idx]=SegmentTree[2ll*idx]+SegmentTree[2ll*idx+1];
  }
}
ll sum(ll idx,ll sl,ll sr,ll l,ll r) //here [sl...sr] segment range associate at idx index. where l and r is query range.
{
    if(l>r)
    {
        return 0;
    }
    if(sl==l && sr==r)
    {
        return SegmentTree[idx];
    }

    ll mid=(sl+sr)/2;
    return sum(2ll*idx,sl,mid,l,min(r,mid))+sum(2ll*idx+1,mid+1,sr,max(mid+1,l),r);
}

void update(ll idx,ll sl,ll sr,ll value,ll id)
{
    if(sl==sr && sl==id)
    {
        SegmentTree[idx]=value;
    }
    else
    {
        ll mid=(sl+sr)/2ll;
        if(id<=mid)
        {
            update(2ll*idx,sl,mid,value,id);
        }
        else
        {
            update(2ll*idx+1,mid+1,sr,value,id);
        }
        SegmentTree[idx]=SegmentTree[2ll*idx]+SegmentTree[2ll*idx+1];
    }
}
/*
note:
//a.resize(unique(a.begin(), a.end()) - a.begin()); use for create array unique element...
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); shuffle(g1.begin(), g1.end(), rng);(g1 is array name) for choose random number
//int grand(int x) {
    return uniform_int_distribution<int>(0, x - 1)(rng);
}
//use once(num) give no of 1 in its binary form
//use give (int)log2(num)+1 give no of digits in its binary form
//bitset<64>(num).to_string() convert decimal to num64 bit binary number
//stoull(str, nullptr, 2) convert str in binary form to decimal number
// "max" priority queue: priority_queue<ll, vector<ll>, less<ll> >pq;   #select max element as top()#
// "min" priority queue: priority_queue<ll, vector<ll>, greater<    ll> >pq; #select min element as top()#
//set<int> inbuit sort accending order (set<int,less<int>>)
//set<int,greater<int>> sort element in decreasing order
// int  __builtin_popcount(unsigned int)
--->It returns the numbers of set bits in an integer (the number of ones in the binary representation of the integer).
///for finding xnor from xor
        x1=Xor
    x2=Xnor
    ll x1=a ^ b;

        ll num=max(a,b);

        ll xx=log2(num)+ 1;   (length of num in binary form)
    ****ll t=(1 << xx) - 1;  (set all xx length bits to 1)
        ll x2=x1 ^ t;            (get xnor via xor using t)
*/

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scl3(a,b,c)          scanf("%lld%lld%lld",&a,&b,&c);
#define scl2(a,b)            scanf("%lld%lld",&a,&b)
#define scd(n)               scanf("%lf",&n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    ll n,w;
    scl2(n,w);
    vector<ll>a(n);
    ll s=0;
    map<ll,ll>mp;
    LOOP(i,n)
    {
        scl(a[i]);
        ll x=a[i]/2;
        if(a[i]%2)x++;
        mp[a[i]]=x;
        s=s+x;
    }
    if(s>w)
    {
        cout << "-1\n";
        return 0;
    }
    srt(a);
    rvs(a);
    ll x=w-s;
    mp[a[0]]=mp[a[0]]+x;
    LOOP(i,n)
    {
        cout << mp[a[i]] << " ";
    }
    cout << "\n";

}

#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
using namespace std;
struct cup{
    int no,v;
}a[105];
bool cmp1(cup c1,cup c2){
    return c1.v>c2.v;
}
bool cmp2(cup c1,cup c2){
    return c1.no<c2.no;
}
int main(){
	int n,w,sum=0;
	cin>>n>>w;
	for(int i=1;i<=n;i++){
        a[i].no=i;
		cin>>a[i].v;
        sum+=(a[i].v+1)/2;
	}
	if(sum>w){cout<<"-1"<<endl; return 0;}
	sort(a+1,a+n+1,cmp1);//cout<<a[1].v<<" "<<a[2].v<<endl;
	int temp=w-sum;//cout<<temp<<endl;
	for(int i=1;i<=n;i++){
		if(temp>(a[i].v/2)) temp=temp-a[i].v/2;
		if(temp<=(a[i].v/2)){//cout<<a[i]/2+1+temp<<endl;
			a[i].v=(a[i].v+1)/2+temp;
			temp=0;
        }
    }
    sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n;i++) cout<<a[i].v<<" ";
    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define ldd long int
#define mp make_pair
using namespace std;

int main() {
	ll n,w,i,s,k,l;
	cin>>n>>w;

	ll a[n+5],b[n+5];
	map< ll ,ll> m;
	map< ll ,ll>:: iterator it;

	s=0;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		m.insert(mp(a[i],i));
		if(a[i]%2==0)
		 b[i]=a[i]/2;
		else
		 b[i]=a[i]/2+1;
		//cout<<b[i]<<' ';
		s+=b[i];

    }

	//cout<<s<<' ';
	if(s>w)
	{
		cout<<-1;
		return 0;

	}

	l=w-s;
	//cout<<l<<' ';
	if(l>0)
	{
	it=m.end();
	it--;
	for( ; it!=m.begin();it--)
	{
		 k=(*it).second;
		 //cout<<a[k]<<' '<<b[k]<<' ';
		 if(l>(a[k]-b[k]))
		 {

		 	l=l-(a[k]-b[k]);
		 	b[k]=a[k];

		 	//cout<<l<<' ';
		 }
		 else
		 {

		 	b[k]+=l;
		 	l=0;
		 	break;
		 }
	}
	if(it==m.begin() && l!=0)
	{
	k=(*it).second;
		 if((l>(a[k]-b[k])))
		 {
		 	l-=(a[k]-b[k]);
		 	b[k]=a[k];

		 }
		 else
		 {
		 	b[k]+=l;
		 	l=0;

		 }
	}

	//cout<<l<<' ';

    if(l!=0)
    {
    	cout<<-1;
    	return 0;
    }
	}
		for(i=0;i<n;i++)
		{

			 cout<<b[i]<<' ';

		}
}

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

#define LL              long long
#define LD              long double
//#define MAX             200005
//#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())
#define BLOCK 555   // Optimum in Most Cases    Mo's Algo see Anudeep Bookamrks

long mul(long a, long b, long c){long long res=(long long)a*b;return(res>=c?res%c:res);}

template <typename T> T mod(T a, T b) {return (a < b ? a : a % b);}
//(a - b) % c
template<typename T> T mod_neg(T a, T b) {a=mod(a, b);if(a<0){a+=b;}return a;}
//(a * b) % c for very large numbers, to avoid overflows
//O(1) hack taken from http://codeforces.com/blog/entry/15884
LL mulmod(LL a,LL b, LL m){LL q=(LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
//(a ^ n)
//Complexity: O(log (n))
template <typename T>T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
//(a ^ n) % m
//Complexity : O(log (n))

template <typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p,m);p=mod(p*p,m);n>>=1;}return x;}
template <typename T>T powerL(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mulmod(x,p,m);p=mulmod(p,p,m);n>>=1;}return x;}

template <typename T> T InverseEuler(T a, T m){return (a==1? 1 : power(a, m-2, m));}
//gcd of 2 numbers a, b
//Complexity: O(log(max(a, b)))
template<typename T> T gcd(T a, T b) { return (b ? __gcd(a,b) : a); }
//lcm of 2 numbers a and b
//Complexity: O(log(max(a, b)))
template <typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}
template<typename T> T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T> T mod_inverse(T a, T n){T x,y;T d = extended_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));}
template<class T> T fast_gcd(T u, T v) {
    long shl = 0; while ( u && v && u != v) { T eu = u & 1; u >>= eu ^ 1; T ev = v & 1; v >>= ev ^ 1;
        shl += (~(eu | ev) & 1); T d = u & v & 1 ? (u + v) >> 1 : 0; T dif = (u - v) >> (sizeof(T) * 8 - 1); u -= d & ~dif; v -= d & dif;
    } return std::max(u, v) << shl;
}
// Most immportant one best optimised
template<class T> bool isPrime(T x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (T i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1;
}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// tree defined...
using namespace __gnu_pbds;
typedef tree <long, null_type, less<long>, rb_tree_tag,
             tree_order_statistics_node_update> ordered_set;
//All indexing is 0-based
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

int main(){

    int n, w, a[100005];
    cin>>n>>w;
    LL s = 0;
    REP(i,n){

        cin>>a[i];
        s += a[i]/2;
    }

    if(s > w){
        cout<<-1;
        return 0;
    }

    int left = w - s;
    int ans[100005];

    REP(i,n){
        if(a[i]%2 == 1){
            ans[i] = a[i]/2;
            if(left >= 1){
                ans[i]++;
                left --;
            }
        }
        else{
            ans[i] = a[i]/2;
        }
    }

    while(left >= 1){
    REP(i,n){
        if(a[i]%2 == 0 && ans[i]+1<=a[i]){
            if(left >= 1){
                ans[i]++;
                left --;
            }
        }
    }

    REP(i,n){
        if(a[i] % 2 == 1 && ans[i]+1<=a[i]){
            if(left >= 1){
                ans[i]++;
                left --;
            }
        }
    }
}

    REP(i,n){
        cout<<ans[i]<<" ";
    }

}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
#define all(v) v.begin(),v.end()
int n,k,sum;
vector<int> v,t;
map<int,int> mp,pp;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i) {
		int a;
		scanf("%d",&a);
		sum+=(a+1)/2;
		v.push_back(a);
	}
	if(sum>k) {
		puts("-1");
		return 0;
	}
	t=v;
	sort(all(t));
//	cout<<sum<<endl;
	sum=0;
	for(int i=0;i<t.size();++i){
		mp[t[i]]=(t[i]+1)/2;
		sum+=(t[i]+1)/2;
	}
	if(sum<k){
		int les=k-sum;
		for(int i=0;i<t.size();++i){
			pp[t[i]]=mp[t[i]];
		}
//		for(int i=0;i<v.size();++i){
//			cout<<mp[v[i]]<<" ";
//		}
//		endl(cout);
		cout<<k<<" "<<sum<<" "<<les<<endl;
		sum=0;
		for(int i=t.size()-1;i>=0;--i){
//			cout<<mp[t[i]]+les<<" "<<t[i]<<" "<<pp[t[i]]<<endl;
			if(mp[t[i]]==pp[t[i]]) mp[t[i]]=min(mp[t[i]]+les,t[i]);
			sum+=mp[t[i]];
			les-=mp[t[i]]-pp[t[i]];
			cout<<mp[t[i]]-pp[t[i]]<<" "<<sum<<" "<<les<<endl;
			if(les==0) break;
		}
	}
	sum=0;
	for(int i=0;i<v.size();++i){
		cout<<mp[v[i]]<<" ";
		sum+=mp[v[i]];
	}
	cout<<endl;
	cout<<sum<<endl;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<ctime>
#include<iomanip>
using namespace std;
int n,w;
struct A{int a,b,i;}a[105];
bool cmp(A a,A b){return a.a>b.a;}
bool cmpp(A a,A b){return a.i<b.i;}
int main(){
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		cin>>a[i].a;
		a[i].b=(a[i].a+1)/2;
		a[i].i=i;
		w-=a[i].b;
	}
	sort(a+1,a+n+1,cmp);
	if(w<0)return cout<<"-1",0;
	for(int i=1;i<=n;i++){
		if(a[i].a-a[i].b>=w){
			w-=a[i].a-a[i].b;
			a[i].b=a[i].a;
		}
		else{
			a[i].b+=w;
			break;
		}
	}
	sort(a+1,a+n+1,cmpp);
	for(int i=1;i<=n;i++) cout<<a[i].b<<" ";
	return 0;
}

#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
int n,w;
pair<int,int> a[500];
int ans[500];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    cin>>n>>w;
    for (int i=1;i<=n;i++) {cin>>a[i].f; a[i].s=i;}
    sort(a+1,a+1+n);
    int sum=0; int cs=0;
    for (int i=1;i<n;i++)
    {   bool kt=0;
        if (a[i].f%2==0)
        {
            cs=max(a[i].f/2,cs);
            if (sum+cs<=w) {ans[i]=cs; sum+=cs; kt=1;}
        }
        if (a[i].f%2!=0)
        {
            cs=max(a[i].f/2+1,cs);
            if (sum+cs<=w) {ans[i]=cs; sum+=cs; kt=1;}
        }
        if (!kt) {cout<<"-1"; return 0;}
    }
    int css=0;
    bool kt=0;
    for (int i=1;i<n;i++) css+=ans[i];
    if (a[n].f%2==0&&w-css>=a[n].f/2&&w-css>=cs) {ans[n]=w-css; kt=1;}
    if (a[n].f%2!=0&&((w-css)>=(a[n].f/2+1))&&w-css>=cs) {ans[n]=w-css; kt=1;}
    if (!kt) {cout<<"-1"; return 0;}
    int du;
    if (ans[n]>a[n].f)
    {du=ans[n]-a[n].f; ans[n]=a[n].f;
    for (int j=n-1;j>=1&&du>0;j--)
    {
        while (ans[j]<a[j].f&&ans[j]<ans[j+1]&&du>0) {ans[j]++; du--;}
    }
    }
     for (int i=1;i<=n;i++) cout<<ans[a[i].s]<<" ";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define f(i,a,b) for(int i = a; i < b; ++i)
const ll N = 1e6 + 7;
int n, w, a[N], h, k, sum, fr[N];
vector<pair<int,pair<int,int> > > ans;
int main() {
    scanf("%d%d",&n,&w);
    f(i,0,n){
        scanf("%d",&a[i]);
        fr[a[i]]++;
        sum += ceil(a[i] / 2.0);
        ans.push_back(make_pair(a[i],make_pair(ceil(a[i] / 2.0),0)));
    }
    if(sum > w)
        return printf("-1"), 0;
    w -= sum;
    sort(ans.begin(),ans.end());
    f(i,0,n)
        ans[i].second.second = fr[ans[i].first];
    while(w){
        k = w;
        f(i,0,n){
            if(w % ans[i].second.second == 0 && ans[i].second.first != ans[i].first){
                if(w / ans[i].second.second + ans[i].second.first < ans[i].first){
                    f(j,i,n){
                        if(ans[i].first != ans[j].first)
                            break;
                        ans[j].second.first += k / ans[j].second.second;
                        w -= k / ans[j].second.second;
                    }
                }else{
                    f(j,i,n){
                        if(ans[i].first != ans[j].first)
                            break;
                        ans[j].second.first = ans[j].first;
                        w -= ans[j].first - ans[j].second.second;
                    }
                }
            }
            if(!w)
                break;
            if(i == n - 1 && k == w)
                return printf("-1"),0;
        }
    }
    f(i,0,n){
        f(j,0,n){
            if(a[i] == ans[j].first){
                printf("%d ",ans[j].second.first);
                break;
            }
        }
    }
    return 0;
}

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <deque>
#include <iterator>
#include <stack>
#include <complex>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <stdio.h>
#include <iomanip>

#define _CRT_SECURE_NO_WARNINGS
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define all(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define ll long long

#define bs 1000000007
#define min(a, b) a<b?a:b
#define max(a, b) a>b?a:b
#define MIN(a, b, c) min(a, (min(b, c)))
#define MAX(a, b, c) max(a, (max(b, c)))
#define Pi acos(-1.0)
#define pi 3.14159265358979

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w", stdout);

	//int q1,q2;
	int n,sum,c;
	vector<int> a,res;

	cin>>n>>sum;

	for (int i=0; i<n; i++)
	{
		cin>>c;
		a.pb(c);
		if (c%2!=0) {res.pb((c/2)+1); sum-=((c/2)+1);} else {res.pb(c/2); sum-=(c/2);}
		if (sum<0) {cout<<"-1"; return 0;}
	}

	/*for (int i=0; i<a.size()-1; i++)
	{
		if (a[i]%2!=0) q1=(a[i]/2)+1; else q1=a[i]/2;
		if (a[i+1]%2!=0) q2=(a[i+1]/2)+1; else q2=a[i+1]/2;
		if (q1>q2) {cout<<"-1"; return 0;}
	}*/

	int j=0;
	while(sum>0)
	{
		if (sum-(a[j]-res[j])>=0) { sum=sum-(a[j]-res[j]); res[j]=a[j];} else {if (res[j]+sum>=a[j]) res[j]=res[j]+sum; sum=0;}
		if (j+1>a.size()-1) j=0; else j++;
	}

	for (int i=0; i<res.size(); i++)
		{

			cout<<res[i]<<" ";
		}
}

#include<bits/stdc++.h>
using namespace std;
int f=0;
void  recur(int ind,int n,int w,int a[],vector<int> ans,int ret[],int dp[][10005])
{

	if(ind==n && w==0)
	{
		f=1;
		for(int i=0;i<n;++i)
			ret[i]=ans[i];
		return;
	}

	else if(ind==n || w<=0)
		return;

	if(f==1)
		return;

	if(dp[ind][w]!=-1)
		return;

	//cout<<ind<<" "<<w<<endl;
	int i;
	if(ind==0)
		i=(a[ind]+1)/2;
	else
		i=max((a[ind]+1)/2,ans[ind-1]);
	for(;i<=a[ind];++i)
	{
		ans.push_back(i);
		if(dp[ind][w]==-1)
			recur(ind+1,n,w-i,a,ans,ret,dp);
		dp[ind][w]=f;
		ans.pop_back();
	}

}

int main()
{
	int n,w;
	scanf("%d%d",&n,&w);
	int a[n];
	vector< pair<int,int> > v;
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		v.push_back(make_pair(a[i],i));
	}
	sort(v.begin(),v.end());
	sort(a,a+n);
	vector<int> ans;
	int ret[n];
	int dp[105][10005];
	memset(dp,-1,sizeof(dp));
	memset(ret,-1,sizeof(ret));
	recur(0,n,w,a,ans,ret,dp);
	if(ret[0]==-1)
		cout<<-1<<endl;
	else
	{
		int res[n];
		for(int i=0;i<n;++i)
		{
			res[v[i].second]=ret[i];
		}
		for(int i=0;i<n;++i)
			printf("%d ",res[i]);
	}
}

#include<bits/stdc++.h>
using namespace std;
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define TR(...)
#endif
const int MOD = 1000000007;
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define SZ(a) (int)(a.size())
#define MP make_pair
typedef long long int 	LL;
const int N = 111;
pair<int, int > a[N];
int g[N];

int main() {
    int n, w;
    cin>>n>>w;
    for(int i = 1;i <= n; ++i) cin>>a[i].F, a[i].S = i;
    sort(a + 1, a + n + 1);
    a[0].F = -111;
    int add = 0;
    for(int i = 1;i <= n; ++i) {
        int id = a[i].S;
        add++;
        int half = 0;
        if(a[i].F & 1) half = (a[i].F + 1)/2;
        else half = a[i].F/2;
        if(add > half) g[i] = add;
        else g[i] = half, add = half;
        w -= g[id];
    }
    if(w < 0) return 0*printf("-1\n");
    int ind = n;
    while(w) {
        if(g[a[ind].S] < a[ind].F)
            g[a[ind].S]++, w--;
        ind--;
        if(ind == 0) ind = n;
    }
    for(int i = 1;i <= n; ++i)
        printf("%d ",g[i]);
    printf("\n");
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define mod 1000000007
#define INF 10000000000000
#define mt make_tuple
#define g0 get<0>
#define g1 get<1>
#define g2 get<2>
#define out(x) cout<<x<<endl;
#define scan(x) cin>>x;

using namespace std;

 bool sortbysec(const pair<double,int> &a,const pair<double,int> &b)
{
    return (a.second < b.second);
}

bool sortbysectuple(const tuple<int, int, int>& a,const tuple<int, int, int>& b)
{
    return (get<1>(a) < get<1>(b));
}

bool sortbyth(const tuple<ll, ll, ll>& a,const tuple<ll, ll, ll>& b)
{
    return (get<2>(a) < get<2>(b));
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);auto hash2 = hash<T2>{}(p.second); return hash1 ^ hash2;
    }
};
ll modpow(ll x,ll y){

  if(y==0) return 1;
  ll u=modpow(x,y/2);
  u=(u*u)%mod;
  if(y%2==1) u=(u*x)%mod;
  return u;
}
ll solution(ll a,ll b,ll &x,ll &y){
  if(b==0){
    x=1;
    y=0;
    return a;
  }
  ll x1,y1;
  ll g=solution(b,a%b,x1,y1);
  x=y1;
  y=x1-y1*(a/b);
  return g;
  // x=x0+k*(b/g) y=y0-k*(a/g) all solutions
}

int main(){

       ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      //  priority_queue<int, vector<int>, greater<> > Q;
	   unordered_map<pair<int, int>, string, hash_pair> um,ba;

         ll n,t,x,sum=0,ma=0,ind=-1,i,prev;

         cin>>n>>t;
         ll a[n];

         vector<pair<ll,ll>>v;

         for(i=0;i<n;i++){
         cin>>x;
         a[i]=x;
         v.pb(mp(x,i));
        }

         sort(v.begin(),v.end());

         int ans[n];

         memset(ans,0,sizeof(ans));

         prev=v[0].fi;
         ma=v[0].fi/2;
         if(v[0].fi%2!=0)
         ma++,sum+=ma;
         else
         sum+=ma;

         v[0].fi=ma;

         for(i=1;i<n;i++){

          x=v[i].fi;
          x/=2;
          if(v[i].fi%2!=0)
          x++;

          if(v[i].fi>prev && ma>=x)
          x=ma+1,ma=x;
          else if(v[i].fi==prev && ma>x)
          x=ma,ma=x;
          else
          ma=x;

          prev=v[i].fi;

          v[i].fi=x;
          sum+=v[i].fi;
        //  cout<<v[i].fi<<" "<<a[v[i].se]<<endl;
        }

         //cout<<sum<<endl;

         if(t<sum){
         cout<<-1<<endl;
         return 0;
        }

          //v[n-1].fi+=(t-sum);
          ll rem=(t-sum);

          for(i=n-1;i>=0;i--){

             if(a[v[i].se]-v[i].fi>=rem)
             v[i].fi+=rem,rem=0;
             else
             rem-=(a[v[i].se]-v[i].fi),v[i].fi=a[v[i].se];
           //  cout<<rem<<endl;
             if(rem==0)
             break;
          }

          sort(v.begin(),v.end(),sortbysec);

          for(i=0;i<n;i++){

            cout<<v[i].fi<<" ";
          }

          //

          return 0;
}

#include<bits/stdc++.h>

using namespace std;

vector<pair<int, int> > pos;
int cup[105];

int main(){
	int n, w;

	cin >> n >> w;

	int tot = 0;

	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		pos.push_back(make_pair(a, i));

		tot += a;
	}

	sort(pos.begin(), pos.end());

	for(int i = 0; i < pos.size(); i++){
		int pint;
		pint = (pos[i].first + 1)/2;

		w -= pint;

		cup[pos[i].second] += pint;
	}

	if(w < 0){
		printf("-1\n");
		return 0;
	}

	int i = n-1;

	while(w > 0){
		i--;
		if(i < 0)
			i = n-1;

		cup[pos[i].second]++;
		w--;
	}

	for(int i = 0; i < n; i++)
		printf("%d%c", cup[i], " \n"[i == n-1]);

	return 0;
}
// 1496280732056

using namespace std;
#include<string.h>
#include <sstream>
typedef long long int ll;
typedef long double ld;
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <map>
//#define N 4
//const ll INF = 0x3f3f3f3f;
//const ll INF = 0x3f3f3f3f3f3f3f3f;
#include <queue>
#include <unordered_set>
#include <math.h>
#include <cstring>
#include <bitset>
#include <numeric>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <queue>
#include <sstream>
#define PI 3.14159265358979323846264338327950
#define mp make_pair
#define inf 1e9
#define endl '\n'
//#define M 1000000007
//#define N 1000000

bool sol(pair<ll, ll> const &a, pair<ll, ll> const &b) {
	return a.first > b.first;
}

bool sol2(pair<ll, ll> const &a, pair<ll, ll> const &b) {
	return a.second < b.second;
}

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	ll n, w;
	cin >> n >> w;

	vector<ll> a(n);
	vector<pair<ll, ll> > v, c;

	ll s = 0;
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];

		v.push_back(mp(a[i], i));

		ll cp = ((a[i] + 1) / 2);
		s += cp;
	}

	if (w < s) {
		cout << -1 << endl;
		return 0;
	}

//	if (w == sum) {
//		for (ll i = 0; i < n; i++) {
//			cout << a[i] << " ";
//		}
//		cout << endl;
//		return 0;
//	}

	sort(v.begin(), v.end(), sol);

//	for (ll i = 0; i < n; i++) {
//		cout << v[i].first << ":" << v[i].second << " ";
//	}
//	cout << endl;

	for (ll i = 0; i < n; i++) {
		ll cp = ((v[i].first + 1) / 2);
		c.push_back(mp(cp, v[i].second));
	}

//	for (ll i = 0; i < n; i++) {
//		cout << c[i].first << ":" << c[i].second << " ";
//	}
//	cout << endl;

//	for (ll i = 0; i < n; i++) {
//		cout << c[i] << " ";
//	}
//	cout << endl;

	vector<pair<ll, ll> > ans;

	ll f = 0;
	for (ll i = n - 1; i >= 0; i--) {
		if (w >= c[i].first) {
			ans.push_back(c[i]);
			w -= c[i].first;
		} else {
			f = 1;
			break;
		}
	}

	if (f) {
		cout << -1 << endl;
		return 0;
	}

	sort(ans.begin(), ans.end(), sol2);

	if (w) {
		for (ll i = 0; i < n; i++) {
			if (w) {
				ll d = a[i] - ans[i].first;
				ans[i].first += d;
				w -= d;
			}
//			cout << ans[i].first << " ";
		}
	}

	for (ll i = 0; i < n; i++) {
		cout << ans[i].first << " ";
	}
	cout << endl;
}

#include<bits/stdc++.h>
using namespace std;
const int n=110;
int a[110];
int main(){
    int n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)cin>>a[i];
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=(a[i]/2)+(a[i]%2);
    }
    if(sum>w)cout<<-1<<endl;
    else{
        int dif=w-sum;
        int v=dif;
        //cout<<v<<endl;
        dif/=n;
        if(dif%n)dif++;
        dif++;
        for(int i=1;i<=n;i++){
            int  val=a[i]/2+(a[i]%2);
            if(v==0){
                cout<<val<<' ';
            }
            else{
                if(v<dif){
                    cout<<a[i]+v;
                    v=0;
                }
                else if(val+dif<=a[i]){
                    v-=dif;
                    cout<<dif+val<<' ';
                }
                else{
                    cout<<a[i]<<' ';
                    v-=(a[i]-val);
                }
            }

        }
    }
}

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

int maxv[105], ansv[105], r[105];

bool cmp(int i, int j) {
	return maxv[i] < maxv[j];
}

int main() {
	int n, w;
	scanf("%d%d", &n, &w);
	for(int i=0; i<n; i++)
		scanf("%d", &maxv[i]), r[i] = i;

	sort(r, r+n, cmp);

	ansv[r[0]] = (maxv[r[0]]+1)/2;
	w -= ansv[r[0]];
	for(int i=1; i<n; i++) {
		ansv[r[i]] = max((maxv[r[i]]+1)/2, ansv[r[i-1]]+(maxv[r[i]]==maxv[r[i-1]]?0:1));
//		if(ansv[r[i]] > maxv[r[i]]) {
//			printf("-1\n"); return 0;
//		}
		w -= ansv[r[i]];
	}

	if(w < 0) {
		printf("-1\n");
		return 0;
	}

	if(w > 0) {
		int d, pos = n-2;
		ansv[r[n-1]] += (d = min(w, maxv[r[n-1]]-ansv[r[n-1]]));
		w -= d;
		while(w > 0 && pos >= 0) {
			ansv[r[pos]] += (d = min(maxv[r[pos]]-ansv[r[pos]], min(w, ansv[r[pos+1]]-ansv[r[pos]]-(maxv[r[pos]]==maxv[r[pos+1]]?0:1))));
			w -= d; pos --;
		}
	}
	for(int i=0; i<n; i++) {
		if(i) printf(" ");
		printf("%d", ansv[i]);
	}
	return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int n, k, x[10000];
pair<int, int> a[10000];
main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
	{
		cin>>x[i];
		a[i].first=x[i];
		a[i].second=i;
		k-=(a[i].first-a[i].first/2);
		a[i].first/=2;
	}
	if(k<0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	for(int i=1; i<=n; i++)
	{
		if(k==0)
			break;
		int s=min(k, a[i].first);
		k-=s;
		a[i].first-=s;
	}
	for(int i=1; i<=n; i++)
		swap(a[i].first, a[i].second);
	sort(a+1, a+n+1);
	for(int i=1; i<=n; i++)
		cout<<x[i]-a[i].second<<" ";
	cout<<endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_map>

using namespace std;

#define IOS         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define Ln          length
#define ff          first
#define ss          second
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> >
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007
#define bp(n)       __builtin_popcount(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define forn(i, a, b) for(ll int i = (a); i <= (b); ++i)
#define rep(i,n)      for(ll i = 0; i < n; ++i)
const ll N = 3e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans2 to avoid signed integer overflow;
// in max,min fxs they have to be of same type like ll,ll or int,int;
int n,tot,a[105],sum,ans[105];
vpii v;
void run(){
    cin>>n>>tot;
    rep(i,n) {
        cin>>a[i];
        ans[i]=(a[i]+1)/2;
        sum+=(a[i]+1)/2;
        v.pb(mk(a[i],i));}
    if(sum>tot){
        cout << "-1\n";
        return;
    }
    sort(rall(v));
    tot-=sum;
    for(int i=0; i<sz(v); ++i)
    {
        ans[v[i].ss]+=min(a[v[i].ss]-ans[v[i].ss],tot);
        tot -= min(a[v[i].ss]-ans[v[i].ss],tot);
        if(tot==0){
            break;
        }
    }
    rep(i,n){
        rep(j,n)
        {
            if(ans[i]<ans[j] && a[i]>a[j]){
                cout << "-1\n";
                return;
            }
        }
    }
    rep(i,n) cout << ans[i] << " ";
}

int main()
{
    IOS;
    int tc;
    tc=1;
    //cin >> tc;
    while(tc--)
        run();
    return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){

	ll n,k; cin>>n>>k; int arr[n];
	for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	int t[n];
	for(int i = 0; i < n; i++){
		t[i] = ceil(arr[i]/2.0);
	}
	for(auto xx : t) cout<<xx<<" "; cout<<"\n";
	bool flag = true;
	for(int i = 1; i < n; i++){
		if(arr[i] > arr[i-1]) {
			if(t[i] < t[i-1]) flag = false;
		}
	} ll co = 0;
	for(int i = 0; i < n; i++) co += t[i];
	if(co > k) { cout<<-1<<"\n"; return 0;}

	if(flag) for(auto xx : t) cout<<xx<<" ";
	else cout<<-1<<"\n";
}

// Abhay Singh Bhadoria ( _Asb_ ) //
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
struct S {
    int no;
    int pos;
} a[N];
bool cmp(S a, S b) {
    return a.no < b.no;
}
int res[N];
int main() {
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i].no;
        a[i].pos = i;
    }
    sort(a + 1, a + n + 1, cmp);
    for(int i = 1; i <= n; ++i) {
        res[a[i].pos] = max(res[a[i - 1].pos], (a[i].no + 1) / 2);
        w -= res[a[i].pos];
    }
    for(int i = n; i >= 1; --i) {
        res[a[i].pos] += max(0, min(a[i].no - res[a[i].pos], w));
        w -= min(a[i].no - res[a[i].pos], w);
    }
    if(w < 0) {
        cout << -1;
    }
    else {
        for(int i = 1; i <= n; ++i) {
            cout << res[i] << ' ';
        }
    }
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn=3000;
struct Node
{   int u,v;
    int num;
};
int cmp1(Node a,Node b)
{  return a.u<b.u;//dadaopxiao
}
int cmp2(Node a,Node b)
{  return a.num<b.num;//dadaopxiao
}
int main()
{   int m;
   int w;
   Node v[maxn];
    scanf("%d%d",&m,&w);
      int sum=0;
      for(int i=0;i<m;i++)
      {  scanf("%d",&v[i].u);
         v[i].v=v[i].u/2+v[i].u%2;
         v[i].num=i;
          sum+=v[i].v;
      }
      if(sum>w){printf("-1\n");return 0;}
      sort(v,v+m,cmp1);
      w-=sum;
      int i=m-1;
      while(w>0)
      {   if(v[i].u-v[i].v>=w)
            {v[i].v+=w;w=0;break;}
            else
                {v[i].v=v[i].u;
            w=w-(v[i].u-v[i].v);
            i--;}
      }
        sort(v,v+m,cmp2);
      for(int x=0;x<m-1;x++)
        printf("%d ",v[x].v);
        printf("%d\n",v[m-1].v);
    return 0;
}

#include <stdio.h>
#include <iostream>
using namespace std;

int cup[105];
int wat[105];

int main(){
	int n,w;
	int now;
	scanf("%d %d",&n,&w);
	for(int i=0;i<n;i++){
		scanf("%d",&cup[i]);
	}
	int sum=0;
	wat[n-1]=cup[n-1]/2+cup[n-1]%2;
	sum+=wat[n-1];
	for(int i=n-2;i>=0;i--){
		if(cup[i]<wat[i+1]){
			printf("-1\n");
			return 0;
		}
		wat[i]=cup[i]/2+cup[i]%2;
		if(wat[i]<wat[i+1]){
			wat[i]=wat[i+1];
		}
		sum+=wat[i];
	}
	if(sum>w){
		printf("-1\n");
		return 0;
	}
	else{

		int left=w-sum;
		//printf("%d\n",left);
		for(int i=0;i<n;i++){
			if (i==0){
				if(cup[i]-wat[i]>=left){
					wat[i]+=left;
					left=0;
					break;
				}
				else{
					left-=cup[i]-wat[i];
					wat[i]=cup[i];
				}
			}
			else{
				now=min(wat[i-1]-wat[i],cup[i]-wat[i]);
				if(now>=left){
					wat[i]+=left;
					left=0;
					break;
				}
				else{
					left-=now;
					wat[i]=now;
				}
			}
		}
		if(left>0){
		//	printf("%d\n",left);
			printf("-1\n");
		//	printf("b\n");
			return 0;
		}

		for(int i=0;i<n;i++){
			printf("%d ",wat[i]);
		}
		printf("\n");

	}

	return 0;

}

#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <stdio.h>
using namespace std;
int n,l;
pair<int,int> a[107];
int ans[107];
int main(){
	cin>>n>>l;
	int sum=0;
	for (int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
		sum+=(a[i].first+1)/2;
    }
	sort(a,a+n);
	if (l<sum){
		cout<<-1<<endl;
	}
	else{
		int t=l-sum;
		if ((a[n-1].first-(a[n-1].first+1)/2)<t){
			ans[a[n-1].second]=a[n-1].first;
			t-=(a[n-1].first-(a[n-1].first+1)/2);
		}
		else{
			ans[a[n-1].second]=(a[n-1].first+1)/2+t;
			t=0;
		}
		for (int i=n-2;i>=0;i--){
			if ((a[i].first-(a[i].first+1)/2)<t){
				ans[a[i].second]=a[i].first;
				t-=(a[i].first-(a[i].first+1)/2);
			}
			else{
				ans[a[i].second]=(a[i].first+1)/2+t;
				t=0;
			}
		}
	}
	cout<<ans[0];
	for (int i=1;i<n;i++){
		cout<<' '<<ans[i];
	}
	cout<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int amin, amax, j, n, m, k1, k2, kol = 0, n1, k, sum = 0, i, f = 0, a, b;
    cin >> n >> b;
    vector <int> mas;
    int mas1[n];
    for(i = 0;i < n;i ++){
        cin >> a;
        mas.push_back(a);
        mas1[i] = a;
    }
    sort(mas. begin(), mas.end());
    vector <int> ans;
    int old = 0, oldmasi = -1;
    for(i = 0;i < n;i ++){
        amin = mas[i] / 2 + mas[i] % 2;
        amax = mas[i];
        f = 0;
        if(mas[i] == oldmasi){
            for(j = amin;j <= amax;j ++){
                if(j >= old){
                    ans.push_back(j);
                    old = j;
                    f = 1;
                    oldmasi = mas[i];
                    kol += j;
                    break;
                }
            }
        } else {
            for(j = amin;j <= amax;j ++){
                if(j > old){
                    ans.push_back(j);
                    old = j;
                    oldmasi = mas[i];
                    f = 1;
                    kol += j;
                    break;
                }
            }
        }
        if(f == 0){
            cout << -1;
            return 0;
        }
    }
    if(kol > b){
        cout << -1;
        return 0;
    }
    for(i = 0;i < n;i ++){
        a = mas1[i];
        for(j = 0;j < mas.size();j ++){
            if(mas[j] == a){
                cout << ans[j] << " ";
                ans.erase(ans.begin() + j);
                mas.erase(mas.begin() + j);
                break;
            }
        }
    }

    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long m,n,fl,sum;
long long a[501],b[251];
struct stu
{
	long long c,w;
}s[501];
bool cmp(stu x,stu y)
{
	return x.c>y.c;
}
int main()
{
	scanf("%lld%lld",&m,&n);
	for(int i=1;i<=m;i++)
	{
	    scanf("%lld",&a[i]);
	    s[i].c=a[i];
	    s[i].w=i;
	    if(a[i]%2==1)
		b[i]=(a[i]+1)/2;
		else
		b[i]=a[i]/2;
        fl+=b[i];
	}
	if(fl>n)
    {
    	cout<<-1;
    	return 0;
    }
    if(fl==n)
    {
     	for(int i=1;i<=m;i++)
	   	printf("%lld ",b[i]);
	   	return 0;
    }
    sort(s+1,s+m+1,cmp);
	sum=n-fl;
		for(int i=1;i<=m&&sum>0;i++)
		{
		int k=a[s[i].w]-b[s[i].w];
		if(sum>k)
		b[s[i].w]=a[s[i].w],sum-=k;
		if(sum>0&&sum<=k)
		b[s[i].w]+=sum,sum=0;
		if(sum<=0)
		break;
	   }
	   if(sum>0)
	   {
	   	cout<<-1;
	   	return 0;
	   }
	   else
	   {
	   	for(int i=1;i<=m;i++)
	   	printf("%lld ",b[i]);
	   	return 0;
	   }
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

#define tr(container,it) \
        for(auto it=container.begin();it<container.end();it++)
#define all(v) (v.begin(),v.end())
#define l long
#define ll long long
#define two double(2.000000000)

using namespace std;

int main() {
    long n,w;
    cin>>n>>w;
    vector<long> a(n),ans(n);
    set<long> s;

    for(int i=0;i<n;i++)
        {cin>>a[i]; s.insert(a[i]);}

    long tmp=n,flag=0;
    set<long> :: iterator it;

    while(tmp!=0&&flag==0&&!s.empty()&&w!=0)
    {
        long top=*(s.begin());

        long i=find(a.begin(),a.end(),top)-a.begin();

        while((find(a.begin(),a.end(),top)!=a.end())&&tmp!=0&&flag==0&&w!=0)
        {
            long req=(a[i]+1)/2;

            if(req>w)
            {
                flag=1;

                break;
            }else
            {

                if(tmp==1&&w!=0)
                {
                    ans[i]=w;
                    w=0;
                    break;

                }else
                {
                    ans[i]=req;
                    //cout<<ans[i]<<endl;
                    w=w-ans[i];
                }

            }

            if(find(a.begin()+i+1,a.end(),top)==a.end())
                break;
            else
                i=find(a.begin()+i+1,a.end(),top)-a.begin();

            tmp--;
        }

        s.erase(s.begin());
        tmp--;

    }

    if(flag==1)
        cout<<-1;
    else
    {
        for(int i=0;i<n;i++)
            cout<<ans[i]<<" ";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int st[100000],sr[100000],sw[100000],sp[100000];
bool cmp(int &x,int &y)
{
    return x>y;
}
int main()
{
    int a,b,sum=0,q,flag=0,sum1=0,vv=1,i,k=0,mm=0;
    scanf("%d%d",&a,&b);
    for(int i=0; i<a; i++)
    {
        scanf("%d",&st[i]);
        sw[i]=st[i];
        if((st[i]/2)*2!=st[i])
            sr[i]=st[i]/2+1;
        else
            sr[i]=st[i]/2;
        sp[i]=st[i]-sr[i];
        sum+=sr[i];
    }
    sort(sw,sw+a,cmp);
    sort(sp,sp+a,cmp);
    if(sum>b)
        puts("-1");
    else
    {
        sum=b-sum;
        for(i=0; i<a; i++)
        {
            if(sum>=sp[i])
            {
                if(sp[i-1]==sp[i])
                {
                    k++;
                    mm=1;
                }
                else
                {
                    k=0;
                }
                flag++;
                sum-=sp[i];
            }
            else
            {
                q=sw[i];
                break;
            }
        }
        if(mm==1)
            k++;
       // printf("+%d %d ",k,q);
        if(i==a)
        {
            q=sw[a-1];
            sum=0;
        }
        for(int i=0; i<a; i++)
        {
            if(i)
                printf(" ");
            if(st[i]>q)
            {
                sum1++;
                if(sum1<=flag)
                    printf("%d",st[i]);
            }
            else if(st[i]==q&&vv)
            {
                if(k!=0)
                {
                    printf("%d",st[i]);
                    k--;
                }
                else
                {
                    printf("%d",sr[i]+sum);
                    vv=0;
                }
            }
            else
            {
                printf("%d",sr[i]);
            }
        }
    }
    puts("");
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int v[105];
int s[105];
int n,w=0,c=0;
void solve(){
   int res=w-c,pos=0;
   while(res){
      if(s[pos]+res>v[pos]){
         s[pos]=v[pos];
         res-=v[pos]-s[pos];
      }
      else{
         s[pos]+=res;
         res=0;
      }
      pos++;
   }
}
int main(){
   cin>>n>>w;
   for(int i=0;i<n;i++){
      scanf("%d",&v[i]);
      s[i]=(v[i]+1)/2;
      c+=(v[i]+1)/2;
   }
   if(c>w){
      puts("-1");
   }
   else{
      solve();
      for(int i=0;i<n;i++){
         if(i) cout<<' ';
         cout<<s[i];
      }
   }
   return 0;
}

#include<stdio.h>
#include<algorithm>
int n,k,w,i,x,ans[110],ans2[110];
struct node{
	int val,ind;
	bool operator<(const node &p)  const{
		return p.val > val;
	}
}a[110];
int max(int a,int b){
	return a > b ? a : b;
}
int main(){
	scanf("%d%d",&n,&w);
	for(i = 0; i < n; i++){
		scanf("%d",&a[i].val);
		a[i].ind = i;
		x += (a[i].val + 1) / 2;
	}
	if(x > w){
		printf("-1\n");
		return 0;
	}
	std::sort(a,a + n);
	for(i = 0; i < n; i++){
		printf("%d ",a[i].val);
	}
	for(i = 0; i < n; i++){
		if(i == 0){
			ans[i] = (a[i].val + 1) / 2;
			if(w < ans[i]) {
				printf("-1\n");
				return 0;
			}
		}
		else{
			ans[i] = (a[i].val + 1) / 2;
			if(a[i].val > a[i - 1].val){
				if(ans[i] < ans[i - 1]) ans[i] = ans[i - 1];
			}
			if(w < ans[i]){
				printf("-1\n");
				return 0;
			}
		}
		ans2[a[i].ind] = ans[i];
		w -= ans[i];
	}
	ans[n - 1] += w;
	ans2[a[n - 1].ind] = ans[n - 1];
	for(i = 0; i < n; i++){
		printf("%d ",ans2[i]);
	}
}

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

void  recur(int ind,int n,int w,int a[],int ans[],int ret[])
{

	if(ind==n && w==0)
	{
		for(int i=0;i<n;++i)
			ret[i]=ans[i];
		return;
	}

	if(ret[ind]!=-1)
		return;

	else if(ind==n || w<=0)
		return;

	//cout<<ind<<" "<<w<<endl;
	int i;
	if(ind==0)
		i=(a[ind]+1)/2;
	else
		i=max((a[ind]+1)/2,ans[ind-1]);
	for(;i<=a[ind];++i)
	{
		ans[ind]=i;
		recur(ind+1,n,w-i,a,ans,ret);
	}

}

int main()
{
	int n,w;
	scanf("%d%d",&n,&w);
	int a[n];
	vector< pair<int,int> > v;
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		v.push_back(make_pair(a[i],i));
	}
	sort(v.begin(),v.end());
	sort(a,a+n);
	int ans[n];
	int ret[n];
	//int dp[105][105];
	memset(ret,-1,sizeof(ret));
	memset(ans,0,sizeof(ans));
	recur(0,n,w,a,ans,ret);
	if(ret[0]==-1)
		cout<<-1<<endl;
	else
	{
		for(int i=0;i<n;++i)
			printf("%d ",ret[v[i].second]);
	}
}

#include<iostream>
using namespace std;

typedef struct tea
{
int capacite;
int contenue;
int verif;
}tee;

int partition( int a[], int l, int r) {
   int pivot, i, j, t;
   pivot = a[l];
   i = l; j = r+1;

   while( 1)
   {
   	do ++i; while( a[i] <= pivot && i <= r );
   	do --j; while( a[j] > pivot );
   	if( i >= j ) break;
   	t = a[i]; a[i] = a[j]; a[j] = t;
   }
   t = a[l]; a[l] = a[j]; a[j] = t;
   return j;
}

void quickSort( int a[], int l, int r)
{
   int j;

   if( l < r )
   {
   	// divide and conquer
        j = partition( a, l, r);
       quickSort( a, l, j-1);
       quickSort( a, j+1, r);
   }

}

int main()
{
int n,w,s=0,i,test=1;
cin >> n >> w;
tee *t=new tee[n];
for (i=0;i<n;i++)
{
cin >> t[i].capacite ;
s=s+t[i].capacite;
t[i].contenue=0;
}
if (s<w)
{
cout << -1;
return 1;
}
if (n==1)
{
if (t[0].capacite>=w) cout 	<< w;
else cout << -1;
return 0;
}
while (w && test)
{
test=0;
for (i=0;i<n && w;i++)
{
if (t[i].contenue<(t[i].capacite/2)+1)
{
t[i].contenue++;
w--;
test=1;
}
}
}

test=1;
while (w && test)
{
test=0;
for (i=0;i<n && w;i++)
{
if (t[i].contenue<t[i].capacite)
{
t[i].contenue++;
test=1;
w--;
}
}
}
if (!w)
{
test=1;
for (i=0;i<n && test;i++)
if 	(t[i].contenue<(t[i].capacite/2)+1) test=0;
}
else test=0;

if (test)
for (i=0;i<n;i++) cout << t[i].contenue << ' ' ;
else cout << -1 ;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
//double num[200005];
struct hu
{
    int now, zong;
}huu[2005];
int main()
{
    int k, sum;
    while(scanf("%d %d", &k, &sum) != EOF)
    {
        int counts = 0;
        memset(huu, 0, sizeof(huu));
        for(int i = 0; i < k; i++)
        {
            scanf("%d", &huu[i].zong);
        }
        for(int i = 0; i < k; i++)
        {
            huu[i].now = huu[i].zong / 2;
            if(huu[i].zong % 2 == 1)
                huu[i].now += 1;
            sum -= huu[i].now;
        }
        if(sum < 0)
        {
            printf("-1\n");
            continue;
        }
        while(sum)
        {
            if(counts == k && sum)
            {
                break;
            }
            if(sum >= huu[counts].zong - huu[counts].now)
            {
                sum = sum - huu[counts].zong + huu[counts].now;
                huu[counts].now = huu[counts].zong;
                counts++;
            }
            else
            {
                huu[counts].now = huu[counts].now + sum;
                sum = 0;
                break;
            }
        }
        if(counts == k && sum)
        {
            printf("-1\n");
            continue;
        }

        for(int i = 0; i < k; i++)
            printf("%d ", huu[i].now);
        printf("\n");
    }
}

#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
struct cup
{
    int rl;
    int real;
    int n;
    int flag=0;
};
int cmp1(struct cup x,struct cup y)
{
    return x.rl>=y.rl;
}
int cmp2(struct cup q,struct cup w)
{
    return q.n<w.n;
}
int main()
{
    struct cup a[110];
    int n=0;int k=0;int sum=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i].rl);
        a[i].n=i;
        sum+=a[i].rl;
    }
    if(k>sum)
    {
        printf("-1");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i].rl%2!=0)
        {
            a[i].real++;
            k--;
            a[i].flag=1;
        }
        a[i].real+=a[i].rl/2;
        k-=a[i].rl/2;
        if(k<0)
        {
            printf("-1");
            return 0;
        }
    }
    sort(a,a+n,cmp1);
    for(int i=0;i<n;i++)
    {
        if(k-(a[i].rl-a[i].real)>0)
        {
            k=k-(a[i].rl-a[i].real);
            a[i].real=a[i].rl;
        }
        else if(k-(a[i].rl-a[i].real)<=0)
        {
            a[i].real+=k;
            k=0;
            break;
        }
    }

    sort(a,a+n,cmp2);
    for(int i=0;i<n;i++)
    {
        printf("%d ",a[i].real);
    }
    return 0;
}

#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;

struct Node{
	int part,ip,ans;
};Node s[101];
int n,w,p;

bool cmp(Node x,Node y);
bool cmp1(Node x,Node y);

bool cmp(Node x,Node y){
	return x.part>y.part;
}

bool cmp1(Node x,Node y){
	return x.ip<y.ip;
}

int main(){
	cin>>n>>w;
	int i;
	for(i=0;i<n;i++){
		cin>>s[i].part;
		s[i].ip=i;
		s[i].ans=ceil(float(s[i].part)/2);
		w-=s[i].ans;
	}
	if(w<0){
		cout<<-1<<endl;
		return 0;
	}
	sort(s,s+n,cmp);
	while(w>0){
		if(s[p].ans<s[p].part){
			s[p].ans++;
		}else{
			p++;
		}
		w--;
	}
	sort(s,s+n,cmp1);
	for(i=0;i<n;i++){
		cout<<s[i].ans<<" ";
	}
	return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

int main() {
	// your code goes here
	int i,n,w,sum=0;
	cin>>n>>w;
	int a[100];
	int b[100];
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum=sum+ceil(a[i]/2.);

	    b[i]=a[i]-ceil(a[i]/2.);
	}
	if(sum>w)
	{
	    cout<<-1;
	}
	else if(sum==w)
	{
	    for(i=0;i<n;i++)
	    {
	        cout<<ceil(a[i]/2.)<<" ";
	    }
	}
	else
	{
	    w=w-sum;
	    int j;
	    int max=0;
	    for(i=0;i<n;i++)
	    {
	        for(j=0;j<n;j++)
	        {
	            if(b[j]>b[max])
	            {
	                max=j;
	            }
	        }
	        if(w>=b[max])
	        {
	            w=w-b[max];
	            b[max]=0;
	        }
	        else if(w>0)
	        {
	            b[max]=w;
	            w=0;
	        }
	        else
	        {
	            break;
	        }
	    }
	    for(i=0;i<n;i++)
	    {
	        cout<<a[i]-b[i]<<" ";
	    }
	}
	return 0;
}

#include <iostream>
#include <algorithm>
struct aaa
{
    int a,b;
}aa[105];
bool cmp(aaa A,aaa B)
{
    return A.a>B.a;
}
int main()
{
    int n,a[105],m,s=0,b[105];
    std::cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        std::cin>>a[i];
        aa[i].a=a[i];
        aa[i].b=i;
        b[i]=(a[i]+1)/2;
        s+=b[i];
    }
    std::sort(aa,aa+n,cmp);
    bool p=0;
    int y;
    if(s>m)
        std::cout<<"-1"<<std::endl;
    else
    {
        m-=s;
        if(m==0)
        p=1;
        if(!p)
        {
            int g=m/n,h=m%n;
            for(int i=0;i<n;i++)
                b[i]+=g;
            for(int i=0;i<h;i++)
                b[aa[i].b]++;
        }
        for(int i=0;i<n-1;i++)
            std::cout<<b[i]<<" ";
        std::cout<<b[n-1]<<std::endl;
    }
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

#define tr(container,it) \
        for(auto it=container.begin();it<container.end();it++)
#define all(v) (v.begin(),v.end())
#define l long
#define ll long long
#define two double(2.000000000)

using namespace std;

bool comparator(const pair<long,long> &p1,const pair<long,long> &p2)
{
    return p1.first<p2.first;
}

int main() {

    long n,w;
    cin>>n>>w;
    vector< pair<long,long> > v(n),v2(n),v3(n);

    for(long i=0;i<n;i++)
    {
        long tmp;
        cin>>tmp;
        v[i]=make_pair(tmp,i);
    }

    v2=v;

    sort(v2.begin(),v2.end(),comparator);
    v3=v2;

    long flag=1,i=0;

    vector<long> fin(n);

    while(w>0&&i<n)
    {
        long req=(v2[i].first+1)/2;
        if(req>w)
        {
            flag=0;
            break;
        }
        else
        {
            w=w-req;
            v3[i].first=req;
        }

        i++;
    }

    if(w>0&&i==n)
    {
        for(i=n-1;i>=0&&w>0;i--)
        {
            long req2=(v2[i].first-v3[i].first);
            if(req2<=w)
                {w=w-req2;
            v3[i].first=v2[i].first;}
            else
            {
                v3[i].first+=req2-w;
                w=0;
            }
        }

    }

    if(flag==0)
        cout<<-1;
    else
    {

        for(int j=0;j<n;j++)
        {
            fin[v3[j].second]=v3[j].first;
        }

        for(int j=0;j<n;j++)
        {
            cout<<fin[j]<<" ";
        }
    }

    return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;

int main(int argc, char const* argv[])
{
  int n, w; cin >> n >> w;
  vector<int> a(n); cin >> a;
  vector<int> e(n);
  sort(whole(e), [&](int i, int j){
    if(a[i] != a[j])return a[i] < a[j];
    return i < j;
  });
  vector<int> res(n, 0);
  rep(i, n){
    res[i] = (a[i] + 1) / 2;
    w -= res[i];
  }
  if(w < 0){
    cout << -1 << endl;
    return 0;
  }
  rep(i, n){
    rep(j, n){
      if(a[j] < a[e[i]] && res[j] > res[e[i]]){
        w -= res[j] - res[e[i]];
        res[e[i]] = res[j];
      }
    }
  }
  if(w < 0){
    cout << -1 << endl;
    return 0;
  }

  rrep(i, n){
    if(w == 0)break;
    int b = a[e[i]];
    rep(j, n){
      if(a[j] > a[e[i]]){
        chmin(b, res[j]);
      }
    }
    int tmp = min(w, b - res[e[i]]);
    if(tmp < 0){
      cout << -1 << endl;
      return 0;
    }
    w -= tmp;
    res[e[i]] += tmp;
  }

  rep(i, n){
    if(res[i] > a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  if(w != 0){
    cout << -1 << endl;
    return 0;
  }
  cout << res << endl;
  return 0;
}

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

pair<int,int> p[105];
pair<int,int> o[105];

int comp(pair<int,int> a,pair<int,int> b)
{
    return a.first>b.first;
}

int comp2(pair<int,int> a,pair<int,int> b)
{
    return a.second>b.second;
}

int main()
{
    int n,w;

    cin >> n >> w;

    for(int i = 1 ; i<=n ; i++)
    {
        cin >> p[i].first;

        p[i].second=i;
    }

    //sort(p+1,p+n+1);

    int tot=0;

    for(int i = 1 ; i<=n ; i++)
    {

        int x=p[i].first/2;
        if(x*2<p[i].first)
        {
            p[i].first=x+1;
            tot+=(x+1);
        }
        else
        {
            p[i].first=x;
            tot+=x;
        }
       // cout << p[i].first.first << endl;
    }

    if(tot>w)
    {
        cout << "-1";
        return 0;
    }
    else if(tot==w)
    {
       // sort(p+1,p+n+1,comp2);
        for(int i = 1 ; i<=n ; i++)
        cout << p[i].first << " ";
        return 0;
    }

    sort(p+1,p+n+1,comp2);

    int x = w-tot,y=1;
    while(x)
    {
        if(x<=p[y].first-1)
        {
            p[y++].first+=x;
            x=0;
        }
        else if(x>p[y].first-1)
        {
            p[y].first+=p[y].first-1;
            x=x-p[y].first-1;
            y++;
        }
    }

    for(int i = 1 ; i<=n ; i++)
    {
        cout << p[i].first << " " ;
    }
return 0;
}

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct d
{
	int v0,v1,k;
}a[105];
bool cmp1(d a,d b)
{
	if(a.v0<b.v0)
	return true;
	else
	return false;
}
bool cmp2(d a,d b)
{
	if(a.k<b.k)
	return true;
	else
	return false;
}
int main()
{
	int n,w,i,j;
	while(scanf("%d%d",&n,&w)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i].v0);
			a[i].v1=(a[i].v0+1)/2;
			a[i].k=i;
			w-=a[i].v1;
		}
		if(w<0)
		{
			printf("-1\n");
			continue;
		}
		sort(a,a+n,cmp1);
		for(i=0;i<n;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(a[j].v0>a[i].v0&&a[j].v1==a[i].v1)
				{
					a[j].v1++;
					w--;
				}
			}
		}
		if(w<0)
		{
			printf("-1\n");
			continue;
		}
		if(w)
		{
			for(i=n-1;i>=0;i--)
		{
			if(a[i].v1<a[i].v0)
			{
				if(a[i].v0-a[i].v1<=w)
				{
					w-=(a[i].v0-a[i].v1);
					a[i].v1=a[i].v0;
				}
				else
				{
				    a[i].v1+=w;
					w=0;
				}
			}
		}
		}
		if(w)
		{
			printf("-1\n");
			continue;
		}
		sort(a,a+n,cmp2);
		for(i=0;i<n;i++)
		{
			printf("%d",a[i].v1);
			if(i!=n-1)
			printf(" ");
			else
			printf("\n");
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[105],cnt[105],ans[105];
int main()
{
    int n,w;
    cin>>n>>w;
    int mn = 1e6;
    for(int i=0;i<n;i++) { scanf("%d",&a[i]); mn = min(mn,a[i]); cnt[a[i]]++; }

    int start = ceil(mn*1.0/2.0); /*cout<<start<<endl;*/
    int sum = 0;
    int flag = 1;
    for(int i=1;i<=100;i++){
        if(cnt[i]!=0){
//            cout<<start<<" ";
            for(int k=1;k<=cnt[i];k++){
            int at_least = ceil(i*1.0/2.0);
            if(start<at_least) start = at_least;
            sum+= start;
            if(sum>w) { cout<<-1; return 0; }
            }
          ans[i] = start;
//          cout<<i<<" "<<cnt[i]<<" "<<start<<endl;
          start++;
        }
        if(sum>w) break;
    }

    int baki = w - sum;

    for(int i=100;i>=1;i--){
        if(cnt[i]!=0){
            int increment = i - ans[i];
            if(baki>=increment) { ans[i]+= increment; baki-=increment; }
            else{
                ans[i]+=baki;
                baki=0;
            }
        }
    }
    if(w==1113) cout<<baki<<endl;
    for(int i=0;i<n;i++)
        printf("%d ",ans[a[i]]);

}

#include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define ins insert
    #define rs resize
    #define br break;
    #define cont continue;
    #define vi vector<int>
    #define vll vector<long long>
    #define si set<int>
    #define sll set<long long>
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define vec vector
    #define cend cout<<endl;
    #define sc second
    #define fr first

    using namespace std;

    //###############--MATHS--##################
    ll modex(ll a,ll b,ll m){
      if(b==0)return 1;
      ll ans=a;
      ll save=1;
      while(b!=1){
          if(b%2==1){
              save*=ans;
             save%=m;
        }
        ans*=ans;
        ans%=m;
        b/=2;
      }
      return (ans*save)%m;
     }

    ll mx,my;

    void solve(ll a,ll b){
      if(b==0){
          mx=1;
          my=0;
          return;
      }
      solve(b,a%b);
      ll x1=mx;
      ll y1=my;
      mx=y1;
      my=x1-(a/b)*y1;
    }

   ll mi(ll x,ll m){
      solve(x,m);
      return (mx+m)%m;
    }
    vector<ll>p;
    vector<bool>prime;
    void seive(int n){
      prime.resize(n+1);
      for(int i=2;i<prime.size();i++)prime[i]=1;
      for(int i=2;i*i<=n;i++){
          if(!prime[i])continue;
          int j=i+i;
          while(j<=n){
            prime[j]=0;
            j+=i;
          }

      }
        for(int i=2;i<=n;i++)if(prime[i])p.pb(i);

    }

    vector<ll>lpd;

    void lpdgen(int n){
      prime.resize(n+1);
      lpd.resize(n+1,0);
      for(int i=2;i<=n;i++)prime[i]=1;
      for(int i=2;i*i<=n;i++){
          if(!prime[i])continue;
          int j=i+i;
          while(j<=n){
            prime[j]=0;
            if(lpd[j]==0)lpd[j]=i;
            j+=i;
          }

      }
        for(int i=2;i<=n;i++)if(prime[i])lpd[i]=i;

    }
    template<typename T>
    vector<T> compfactor(T x){
      vector<T>ret;
      while(x!=1){
        ret.pb(lpd[x]);
        x/=lpd[x];
      }
      return ret;
    }
    template<typename T>
    vector<T> pfactor(T x){
      vector<T>ret;
      while(x!=1){
        if(ret.size()==0 || ret[ret.size()-1]!=lpd[x])ret.pb(lpd[x]);
        x/=lpd[x];
      }
      return ret;
    }

    vector<ll>fact;
    void factgen(ll n,ll m){
      fact.resize(n+1);
      fact[0]=1;
      for(ll i=1;i<=n;i++){fact[i]=i*fact[i-1];fact[i]%=m;}
    }
    template<typename T>
    vector<T> factor(T x){
      vector<T>ret;
      for(ll i=1;i*i<=x;i++){
        if(i*i==x){
          ret.push_back(i);
          break;
        }

        if(x%i==0){ret.push_back(i);ret.push_back(x/i);}
      }
      return ret;

    }

    //##########################################

    //#######--initializers--###################
        template<typename T>
        void init(vector<T>& x,T n){
          for(int i=0;i<x.size();i++)x[i]=n;
        }
        template<typename T>
        void init2(vector<vector<T> >& x,T n){
          for(int i=0;i<x.size();i++)
            for(int j=0;j<x[i].size();j++)x[i][j]=n;
        }
      template<typename T>
        void init3(vector<vector<vector<T> >  >& x,T n){
          for(int i=0;i<x.size();i++)
            for(int j=0;j<x[i].size();j++)
                for(int k=0;k<x[i][j].size();k++)x[i][j][k]=n;
        }

        template<typename T>
        void inits2(vector<vector<T> >& x,int a,int b){
          x.rs(a);
          for(int i=0;i<x.size();i++)x[i].rs(b);
        }
      template<typename T>
        void inits3(vector<vector<T> >& x,int a,int b,int c){
          x.rs(a);
          for(int i=0;i<x.size();i++){x[i].rs(b);for(int j=0;j<x[i].size();j++)x[i][j].rs(c);}
        }

    //############################################

    //#########--min&&max--##############
      template<typename T>
      T minarr(T* arr,int n){
        T x=arr[0];
        for(int i=0;i<n;i++)x=min(x,arr[i]);
        return x;
      }
      template<typename T>
      T maxarr(T* arr,int n){
        T x=arr[0];
        for(int i=0;i<n;i++)x=max(x,arr[i]);
        return x;
      }
      template<typename T>
      T minarr(vector<T>& arr){
        T x=arr[0];
        for(int i=0;i<arr.size();i++)x=min(x,arr[i]);
        return x;
      }
      template<typename T>
      T maxarr(vector<T>& arr){
        T x=arr[0];
        for(int i=0;i<arr.size();i++)x=max(x,arr[i]);
        return x;
      }

    //###################

    //#############

    //############--printer&&scanner--############

    template<typename T>
    void prt(vector<T>& x,int n){
      for(int i=0;i<n;i++)cout<<x[i]<<" ";
    }
    template<typename T>
    void prt(T* x,int n){
      for(int i=0;i<n;i++)cout<<x[i]<<" ";
    }
    template<typename T>
    void prtl(vector<T>& x,int n){
      for(int i=0;i<n;i++)cout<<x[i]<<endl;
    }
    template<typename T>
    void prtl(T* x,int n){
      for(int i=0;i<n;i++)cout<<x[i]<<endl;
    }
    template<typename T>
    void scan(T* arr,int n){
      for(int i=0;i<n;i++)cin>>arr[i];
    }
    template<typename T>
    void scan(vector<T>& ret,int n){
      for(int i=0;i<n;i++)cin>>ret[i];
    }

    //#################--string--################

    vector<int> failure(string& s){
      vector<int> f(s.size(),0);
      int ex=0;
      for(int i=1;i<s.size();i++){
        while(ex!=0 && s[ex]!=s[i])ex=f[ex-1];
        if(ex==0){
          if(s[ex]!=s[i]){
            f[i]=0;
            ex=0;
            continue;
          }
        }
        f[i]=ex+1;
        ex++;
      }
      return f;
    }

    //###########################################

    int main(){
      int n,w;
      cin>>n>>w;
      if(n==1){
        int c;
        cin>>c;
        if(w>=(c+1)/2){
          cout<<w<<endl;
        }
        else cout<<-1<<endl;
        return 0;
      }
      pair<int,int> arr[n];
      for(int i=0;i<n;i++){cin>>arr[i].fr;arr[i].sc=i;}
        sort(arr,arr+n);
        int ans[n];
      int tot=0;
      for(int i=0;i<n-1;i++){
        ans[arr[i].sc]=(arr[i].fr+1)/2;
        tot+=(arr[i].fr+1)/2;
      }
      ans[arr[n-1].sc]=min(w-tot,arr[n-1].fr);
      if(ans[arr[n-2].sc]>ans[arr[n-1].sc] || ans[arr[n-1].sc]<(arr[n-1].fr+1)/2){
        cout<<-1<<endl;
        return 0;
      }

      tot+=ans[arr[n-1].sc];
      int r=w-tot;

      for(int i=n-2;i>=0;i--){
        if(r==0)break;
        int xxx=arr[i+1].fr-arr[i].fr;
        int xxxx=min(r,xxx);
        r-=xxxx;
        ans[arr[i].sc]+=xxxx;
      }

      if(r!=0){
        cout<<-1<<endl;
        return 0;
      }

      for(int i=0;i<n;i++)cout<<ans[i]<<" ";

    }

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ll n, k,c = 0, ar[100009], arr[100009];
	cin >> n >> k;
	for(ll i = 0; i < n; i++)
	{
		cin >> ar[i];
		arr[i] = ar[i] - ar[i] / 2;
		k = k - arr[i];
	}
	if(k <= 0)
	   {
	   	cout <<"-1";
	   	return 0;
	   }
	   while(k > 0)
	   {
	   c = -1;
		 for(ll i =0; i < n; i++)
		 {
		 	  if(ar[i] !=arr[i] && (c == -1 || ar[i] > ar[c]))
		 	     c = i;
		 	     if(c == -1)
		 	     {
		 	     	cout << "-1";
					return 0;
		 	     }
		 	     k--;
		 	     arr[c]++;
		 	 }
     }
     for( ll i = 0; i < n; i++)
     cout << arr[i] <<" ";

}

#include <unordered_map>
#include <vector>
#include <cmath>
#include <iostream>
#include <utility>
#include <functional>
#include <algorithm>

using namespace std;

void solve(int n, int w)
{
    vector<int> a(n);
    vector<int> b(n);

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

    for(int i=0; i<n; i++)
    {
        b[i] = a[i]/2 + a[i]%2;
        w -= b[i];
    }

    for(int i=0; i<n && w>=0; i++)
    {
        int max = 0;
        for(int k=0; k<n; k++)
        {
            if(a[k] > max && b[k] < a[k])
                max = k;
        }
        //int x = min(a[i]-b[i], w);
        int x = min(a[max]-b[max], w);
        b[max] += x;
        w -= x;
    }

    if(w != 0)
        cout << -1 << endl;
    else
    {
        for(int i=0; i<n; i++)
            cout << b[i] << " ";
        cout << endl;
    }
}

int main()
{
    int n, w;

    cin >> n;
    cin >> w;

    solve(n, w);

    return 0;
}

// 1495220413916

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

bool comp (const pair<const pair<int,int>,int> &a,const pair<const pair<int,int>,int> &b)
{
  return a.first.first>b.first.first;
}

bool cmp (const pair<const pair<int,int>,int> &a,const pair<const pair<int,int>,int> &b)
{
  return a.second<b.second;
}

int main()
{
  int n,w;
  cin >> n >> w;
  vector<pair<pair<int,int>,int>> v;
  //vector<pair<int,int>> ans;
  int initsum = 0;
  for(int i=0;i<n;i++)
  {
    int k;
    cin >> k;
    v.push_back(make_pair(make_pair(k,0),i));
    //ans.push_back(make_pair(0,i));
    v[i].first.second=ceil(float(v[i].first.first)/2);
    initsum+=v[i].first.second;
  }
  if(initsum > w) cout << -1 << endl;
  else
  {
    sort(v.begin(),v.end(),comp);
    //sort(ans.begin(),ans.end(),comp);
    int rem = w - initsum;
    for(int i=0;i<n;i++)
    {
      if(rem>=(v[i].first.first-v[i].first.second))
      {
        v[i].first.second=v[i].first.first;
        rem-=(v[i].first.first-v[i].first.second);
      }
      else if(rem > 0)
      {
        v[i].first.second+=rem;
        rem=0;
      }
      else break;
    }
    sort(v.begin(),v.end(),cmp);
    for(int i=0;i<n;i++)
    {
      cout << v[i].first.second << " ";
    }
  }

  return 0;
}

//$ time g++ -c -std=c++11 vec.cpp -fconstexpr-depth=600
//#pragma comment(linker, "/STACK:36777216")
//OPT COMPILER:global compiler c++11
//Lex MOD-0 ver. 2.3 (19/06/2018)
//{
#include<bits/stdc++.h>
#define ll                  long long
#define rep(i,n)            for(auto i=0;i<(n);++i)
#define pb                  push_back
#define mp                  make_pair
#define f                   first
#define s                   second
#define sz(v)               v.size()
#define all(v)              std::begin(v), std::end(v)
#define vi                  vector<int>
#define mod                 1000000007LL

#define StringToInt(s,n)    if ( ! (istringstream(s) >> n) ) n = 0;
using namespace std;
template <typename T>
string NumberToString ( T Number ){
	std::ostringstream ss; ss << Number; return ss.str();}

#ifdef ONLINE_JUDGE
#define line
#define o(x)
#else
#define line                cerr<<'\n';
#define o(x)				cerr << __LINE__ << " $" << #x << " = " << x << "\n";
#endif // ONLINE_JUDGE

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
inline int read() {
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
//}

#define _sayeb  false
#define _5outh  true
	int n;
	vector<int> gess,p,a,cum;

bool getB(int lo, int hi, int i){
	int mid;
while(lo<=hi){
		o(mid)
		o(lo)
		o(hi)
		line
	mid = (lo+hi)/2 +(lo+hi)%2;
	if (a[p[mid]]<a[p[i+1]]){
		if (lo==mid) break;
		lo=mid;
	}else{
		hi=mid-1;
	}
}
return mid;
}

bool bs(int i, int lo , int hi, int restant){
	/*o(i)
	o(lo)
	o(hi)
	line*/
if (restant<lo*(n-i) || restant< (cum[n]-cum[i])/2)  return _sayeb;

if ( restant>(cum[n]-cum[i])) return _5outh;
if (i==n-1){
	if (restant<=hi && restant>=lo){
		gess[p[i]] = restant;
		rep(i,n) cout<<gess[i]<<" ";
		exit(0);
	}
	if (restant>hi) return _5outh;//x>=lo; //// && ;
	if (restant<lo) return _sayeb;
}

int nlow ;
bool ans=_sayeb;
while(lo<=hi){
	gess[p[i]] = (lo+hi)/2 +(lo+hi)%2;
	//o(gess[p[i]])
	nlow = (a[p[i+1]]+1)/2;
	if (i<6){
		if (a[p[i+1]]>a[p[i]]) rep(j,i+1) nlow = max(nlow, gess[p[i]]+1 );
	}else{
		int before = getB(0,i,i);
		if (a[p[before]]<a[p[i+1]]) nlow = max(nlow, gess[p[before]] );

	}
	ans = bs(i+1, nlow, min(a[p[i+1]], restant), restant-gess[p[i]]);
	if (ans){
		lo=gess[p[i]];
	}else{
		hi=gess[p[i]]-1;
	}
}
return ans;
}

int main() {
#ifndef ONLINE_JUDGE
//freopen("a.txt", "r", stdin);
#endif // ONLINE_JUDGE
	ios::sync_with_stdio(0);
	cin.tie(0);	cout.tie(0);
	//cout << fixed << setprecision(9);
	int w;
 cin >> n>>w;
	gess.resize(n);
	a.resize(n);
	p.resize(n);
	cum.resize(n+1);
	for(auto& e:a)cin>>e;
	rep(i,n) p[i]=i;
	sort(all(p),[=](int i, int j){return a[i]<a[j];} );

	cum[0] = 0;
	rep(i,n) cum[i+1]=cum[i]+a[p[i]];

	bs(0,(a[p[0]]+1)/2,a[p[0]], w);

	cout<<-1;
	return 0;}

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int n,w,k;
	int start=0;
	std::cin>>n>>w;
	std::vector<int> v(n);
	std::vector<int> f(n,0);
	for(int i=0;i<n;i++)
		std::cin>>v[i];
	std::sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		if(v[i]%2)
		{
			++v[i];
			f[i]=1;
		}
		v[i]=v[i]/2;
		w=w-v[i];
	}
	if(w<0)
	{
		std::cout<<-1<<"\n";
		return 0;
	}
	while(w>0)
	{
		if((v[start]-f[start])>=w)
		{
			v[start]+=w;
			w=0;
			break;
		}
		v[start]+=v[start]-f[start];
		w=w-v[start]-f[start];
		start++;
	}
	for(int i=0;i<n;i++)
		std::cout<<v[i]<<" ";
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
struct cup
{
    int rl;
    int real;
    int n;
};
int cmp1(struct cup x,struct cup y)
{
    return x.rl>y.rl;
}
int cmp2(struct cup q,struct cup w)
{
    return q.n<w.n;
}
int main()
{
    struct cup a[110];
    int n=0;int k=0;int sum=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i].rl);
        a[i].n=i;
        sum+=a[i].rl;
    }
    if(k>sum)
    {
        printf("-1");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i].rl%2!=0)
        {
            a[i].real++;
            k--;
        }
        a[i].real+=a[i].rl/2;
        k-=a[i].rl/2;
        if(k<0)
        {
            printf("-1");
            return 0;
        }
    }
    sort(a,a+n,cmp1);
    for(int i=0;i<n;i++)
    {
        if(k-(a[i].rl-a[i].real)>0)
        {
            k=k-(a[i].rl-a[i].real);
            a[i].real=a[i].rl;
        }
        else if(k-(a[i].rl-a[i].real)<=0)
        {
            a[i].real+=k;
            k=0;
            break;
        }
    }

    sort(a,a+n,cmp2);
    for(int i=0;i<n;i++)
    {
        printf("%d ",a[i].real);
    }
    return 0;
}
//

//__________________Do_What_You_want___//
//__________I_DO_What_I_Want___________________________//

#include<bits/stdc++.h>
#include <map>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/detail/standard_policies.hpp"
using namespace __gnu_pbds;
using namespace std ;

//----------------------------------INDEX_TREE-----------------------------------------//
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> multiordered_set;

//-------------------------------------------------------------------------------------//
#define pb push_back
#define eb emplace_back
#define F first
#define mk make_pair
#define S second
#define siz(v) (int)v.size()
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define int long long
const int mod = 1e9 + 7  ;
//------------------------------FUNCTIONS----------------------------------------------//
int powermod(int a,int b){int res=1;while(b){if(b&1)(res*=a)%=mod;b/=2;(a*=a)%=mod;}return res%mod;}

int power(int a,int b){int res=1;a%=mod;while(b){if(b&1)res*=a;b/=2;a*=a;}return res;}

bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

vector<int> sieve(int n){vector<int> prime ;vector<int> vis(n+1,false);
for(int i=2;i*i<=n;i++){if(vis[i] == false){for(int j=i*i;j<=n;j+=i){vis[j]=true;}}}
for(int i=2;i<=n;i++){if(vis[i]==false){prime.push_back(i);}}return prime;}

long double to_deg(long double x) { return x * 180 / acos(-1); }
int logi(int x){int p = 0 ;while(x>1){p++;x/=2;}return p ;}
//-------------------------------------------------------------------------------------//

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //--------------------------------input/output-------------------------------------//
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    //----------------code-------------------------------------------------------------//

    int n,w;
    cin>>n>>w;
    vector<pair<int,int>> a(n);
    int sum = 0 ;
    for(int i=0;i<n;i++){
        cin>>a[i].F;
        sum += a[i].F/2 ;
        if(a[i].F&1) sum ++ ;
        a[i].S = i ;
    }

    if(sum > w) return cout<<-1,0;
    sort(all(a)) ;
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        ans[a[i].S] = ( a[i].F/2 ) + ( a[i].F % 2 ) ;
        w -= ans[a[i].S];
    }
    if(w>0){
        int cur = a.back().F - ans[a.back().S] ;
        int p = min(cur , w) ;
        w -= p ;
        ans[a.back().S] += p ;
        for(int i=n-2;i>=0;i--){
            p = min( a[i].F - ans[a[i].S] , ans[a[i+1].S] );
            if( w <= 0 ) break;
            if(w > p){
                w -= p;
                ans[a[i].S] += p ;
            }else if(w<=p){
                w -= p;
                ans[a[i].S] += p ;
                break;
            }
        }
    }
    if(w>0) return cout<<-1,0;
    for(int i=0;i<n;i++) cout<<ans[i]<<" ";
    cout<<endl;
}

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int a, site, ans;
}cup[1002];
bool cmp(const node& x, const node& y)
{
    return x.a < y.a;
}
bool cmp2(const node& x, const node& y)
{
    return x.site < y.site;
}
int main()
{
    int n, w;
    cin >> n >> w;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> cup[i].a;
        cup[i].site = i;
        if(cup[i].a % 2 == 1)
            cup[i].ans = cup[i].a / 2 + 1;
        else cup[i].ans = cup[i].a / 2;

        sum += cup[i].ans;
    }
    if (sum > w) {
        cout << "-1" << endl;
    }
    else {
        sort (cup + 1, cup + n + 1, cmp);
        int j = n;
        int last = w - sum;
        while (last > 0) {
            if(cup[j].a - cup[j].ans <= last) {
                cup[j].ans = cup[j].a;
                last = last - (cup[j].a - cup[j].ans);
            }
            else {
                cup[j].ans += last;
                last = 0;
            }
            --j;
            if(j == 0) break;
        }
        sort (cup + 1, cup + n + 1, cmp2);
        for (int i = 1; i <= n; ++i) {
            if(i - 1) cout << " ";
            cout << cup[i].ans;
        }
        cout << endl;
    }
    return 0;
}

#include <bits/stdc++.h>

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    int a[n];
    vector<pair<int,int>> vec;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        vec.push_back({a[i],i});
    }
    sort(vec.begin(), vec.end());
    int res[n];
    for (int i = 0; i < n; i++) {
        res[i] = a[i]/2;
        if (a[i] % 2 == 1) res[i]++;
        w -= res[i];
    }
    if (w >= 0) {
        for (int i = n-1; i >= 0; i--) {
            res[vec[i].second] += min(w, vec[i].first-res[vec[i].second]);
            w -= min(w, vec[i].first-res[vec[i].second]);
        }
        for (int i = 0; i < n; i++) cout << res[i] << ' ';
        cout << '\n';
    } else {
        cout << "-1\n";
    }
}
/*

 */

#include<bits/stdc++.h>
using namespace std;
long long n,m,k,ans,sum,i,j,a[1000009],b[1000009];
double x;
int main()
{
 	cin>>n>>k;
 	for(i=1;i<=n;i++)
 	cin>>a[i];
 sort(a+1,a+1+n);
 for(i=1;i<=n;i++)
 {
     if(k<0){cout<<"-1"<<endl;return 0;}
     k-=(a[i]+1)/2;
     b[i]=(a[i]+1)/2;
 }

 if(a[n]<k){cout<<"-1"<<endl;return 0;}
 else
 b[n]+=k;
 for(i=1;i<=n;i++)
 cout<<b[i]<<" ";
					 return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool compare(pair<int,int> &a,pair<int,int> &b)
{
    return a.first < b.first ;
}
int main()
{
    int n,w;
    cin>>n>>w;
    vector< pair<int,int> > a;
    int f[n],i;
    for(i=0;i<n;i++) f[i]=0;

    for(i=0;i<n;i+=1)
    {
        int x;
        cin>>x;
        a.push_back({x,i});
    }
    sort(a.begin(),a.end(),compare);
    bool flag=true;
    for(i=n-1;i>=0;i--){
      //  cout<<a[i].first<<endl;
        if(a[i].first%2){
                f[a[i].second]+=a[i].first/2 + 1;
            w-=a[i].first/2 + 1;
        }
        else{
             // cout<<"vvb\n";
                f[a[i].second]+=a[i].first/2;
                w-=a[i].first/2;
        }
        if(w<0)
        {
            flag=false;
            break;
        }
    }
    if(flag==false)
    {
        cout<<"-1\n";
        return 0;
    }
    while(w>0)
    {
        int t = true;
        for(i=n-1;i>=0;i--)
        {
            if(w==0)
                break;
            if(f[a[i].second]==a[i].first)
                continue;
            t = false;
            if(a[i].first%2)
                f[a[i].second]++;
            else
                f[a[i].second]++;
            w--;
        }
        if(t)
            break;
    }
   // for(i=0;i<n;i++)

    flag=true;
    for(i=0;i<n;i++)
    {
        if(a[a[i].second].first%2)
        {
            if(f[i]<a[a[i].second].first/2+1)
            {
                flag=false;
                break;
            }
        }
        else if(f[i]<a[a[i].second].first/2)
        {
            flag=false;
            break;
        }
    }
    if(flag==false)
    {
       // cout<<"vivek\n";
        cout<<"-1\n";
        return 0;
    }
    for(i=0;i<n;i++)
        cout<<f[i]<<" ";
    cout<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
#define OK          pf("YES\n")
#define _OK         pf("NO\n")
#define all(v)      v.begin(), v.end()
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k;
    cin>>n>>k;
    ll ar[n];
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n,greater<ll>());
    vector<ll>v;
    bool f=true;
    for(i=n-1; i>=0; i--)
    {
        ll r=ar[i]/2;
        if(ar[i]&1) r++;
        if(r>k)
        {
            f=false;
            break;
        }
        v.pb(r);
        k=k-r;
    }
    if(f==false)
    {
        cout<<-1<<endl;
        return 0;
    }
    reverse(v.begin(),v.end());
    for(i=0; i<n; i++)
    {
        ll r=ar[i]-v[i];
        if(k>=r){
            v[i]=ar[i];
            k=k-r;
        }
        else{
            v[i]+=k;
            k=0;
            break;
        }
    }
    ll ss=v.size();
    for(i=0; i<ss; i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
    return 0;
}
//https://github.com/me-shaon/bangla-programming-resources

#include<bits/stdc++.h>
using namespace std;
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define TR(...)
#endif
const int MOD = 1000000007;
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define SZ(a) (int)(a.size())
#define MP make_pair
typedef long long int 	LL;
const int N = 111;
pair<int, int > a[N];
int g[N];

int main() {
    int n, w;
    cin>>n>>w;
    for(int i = 1;i <= n; ++i) cin>>a[i].F, a[i].S = i;
    sort(a + 1, a + n + 1);
    a[0].F = -111;
    for(int i = 1;i <= n; ++i) {
        int id = a[i].S;
        if(a[i-1].F == a[i].F - 1) g[id] = (a[i].F + 1)/2 + 1;
        else {
            if(a[i].F & 1) g[id] = (a[i].F + 1)/2;
            else g[id] = a[i].F / 2;
        }
        w -= g[id];
    }
    if(w < 0) return 0*printf("-1\n");
    int ind = n;
    while(w) {
        if(g[a[ind].S] < a[a[ind].S].F)
            g[a[ind].S]++, w--;
        ind--;
        if(ind == 0) ind = n;
    }
    for(int i = 1;i <= n; ++i)
        printf("%d ",g[i]);
    printf("\n");
    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

const int N = 1e6 + 7;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int32_t main(){

	IO

	int n,w;
	cin >> n >> w;

	vpi v;
	vi a(n);

	fo(i,0,n) cin >> a[i] , v.eb(a[i] , i);

	sort(all(v));
	reverse(all(v));

	vi ans(n);

	int sum = 0;

	fo(i,0,n){
		ans[i] = (a[i] + 1) / 2;
		sum += ans[i];
	}

	if(sum > w){
		cout << -1;
		return 0;
	}

	fo(i,0,n){
		int x = min(a[i] - ans[i] , w - sum);
		ans[i] += x;
		sum += x;
	}

	for(auto i : ans)
		cout << i << ' ';

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#define ll long long
using namespace std;

int main()
{
    int n,w;
    cin>>n>>w;
    int a[100];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int b[100]={0};
    int y=0;
    while(y!=n)
    {
        for(int i=0;i<n;i++)
        {
            if(a[i]%2==0&&b[i]<a[i]/2&&w!=0)
            {
            b[i]++;
                w--;
                if(b[i]==a[i]/2)
                    y++;
                continue;
            }
            if(a[i]%2!=0&&b[i]<(a[i]/2)+1&&w!=0)
            {
                b[i]++;
                w--;
                if(b[i]==a[i]/2+1)
                    y++;
                continue;
            }

        }
        if(w==0&&y!=n)
        {
            cout<<-1<<endl;
            exit(0);
        }
    }
    if(w!=0)
    {
        for(int i=0;i<n;i++)
        {
            if(w-(a[i]-b[i])<=0)
            {
                b[i]+=w;
                w=0;
                break;
            }
            b[i]=a[i];
            w-=a[i]-b[i];
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }
    cout<<endl;
    return 0;
}

#include <iostream>
#include <stdio.h>
using namespace std;

long long ans, w;
int i, n, x, nom[105];

int main()
{
	scanf("%d%d", &n, &w);
	for (i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        if (x % 2 != 0)
        {
            ans = (long long) ans + x / 2 + 1;
            nom[i] = x / 2 + 1;
        }
        else
        {
            ans = (long long) ans + x / 2;
            nom[i] = x / 2;
        }
    }
    if (ans <= w)
    {
        for (i = 1; i <= n; i++) printf("%d ", nom[i]);
    }
    else printf("-1");
	return 0;
}

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

	vector<int> arr(101);

	int main()
	{
		int n,k;
		cin>>n>>k;
		for(int i=0;i<n;i++)
		cin>>arr[i];

	    long long sum = 0;

	    for(int i=0;i<n;i++)
	    {
	      sum+=arr[i]/2 + arr[i]%2;
		}
	//	cout<<sum<<endl;
		if(sum>k)
		{
			cout<<-1;
			return 0;
	    }
	    vector<int> cup;

		for(int i=0;i<n;i++)
		{
		   cup.push_back(arr[i]/2 +arr[i]%2);
		}

		long long diff = k -sum;

		//sort(cup.begin(),cup.end());
	    for(int i=0;i<n&& diff>0;i++)
	    {
	        if(diff<=0) break;

			if(cup[i]+diff<=k)
	    	{
	    		long long var =  k- cup[i];
	    	    cup[i]+=diff;
	    	    break;
	        }
	    	else
	    	{
	    		long long var = k - cup[i];
	    		cup[i] += var;
	    	    diff -= var;
			}

		}
	    for(int i=0;i<n;i++)
		{
			if(cup[i]>k)
			{
				return cout<<"-1",0;
			}
		}
        sum=0;
	    for(int i=0;i<n;i++) sum+= cup[i];
	    if(sum!=k)
	    return cout<<"-1",0;

		for(int i=0;i<cup.size();i++)
		cout<<cup[i]<<" ";
		return 0;
	}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#define maxn 250
using namespace std;

struct node{
    int i, x, y;
}num[maxn];

bool cmp1(node a, node b)
{
    return a.x<b.x;
}

bool cmp2(node a, node b)
{
    return a.i < b.i;
}

int main(void)
{
    int n, w;
    while(cin >> n >> w){
        memset(num,0,sizeof(num));
        int flag = 0;
        for(int i = 1; i <= n; i++){
            num[i].i = i;
            scanf("%d",&num[i].x);
        }
        sort(num+1,num+1+n,cmp1);
        for(int i = 1; i <= n; i++){
            num[i].y = num[i].x&1?num[i].x/2+1:num[i].x/2;
            w -= num[i].y;
            if(w < 0) flag = 1;
        }
        if(flag)  {printf("-1\n");continue;}
        if(w==0){
            sort(num+1,num+1+n,cmp2);
            printf("%d",num[1].y);
            for(int i = 2; i <= n; i++) printf(" %d",num[i].y);
            printf("\n");
        }
        else{
            for(int i = n; i >= 1; i--){
                if(w>num[i].x-num[i].y){
                    num[i].y = num[i].x;
                    w -= num[i].x-num[i].y;
                }
                else{
                    num[i].y += w;
                    break;
                }
            }
            sort(num+1,num+1+n,cmp2);
            printf("%d",num[1].y);
            for(int i = 2; i <= n; i++) printf(" %d",num[i].y);
            printf("\n");
        }
    }
    return 0;
}
//
//int n, w;
//int flag;
//
//struct node{
//    int i;
//    int x;
//    int y;
//}num[maxn];
//
//bool cmp1(node a, node b)
//{
//    return a.x<b.x;
//}
//
//bool cmp2(node a, node b)
//{
//    return a.i<b.i;
//}
//
//void dfs(int step,int ww,int pre)
//{
//    cout << "ww:" << ww << endl;
//    if(step>n){if(ww==w)flag = 1;else if(ww>w) flag = 2;return;}
//    if(flag==1||flag==2) return ;
//    for(int i = num[step].x&1?num[step].x/2+1:num[step].x/2; i <= num[step].x; i++){
//        if(pre>i) continue;
//        num[step].y = i;
//        cout << step << " " << pre << " " << i << " " << num[step].y<< " " << ww << endl;
//        if(flag==1||flag==2) return;
//        dfs(step+1,ww+i,i);
//    }
//}
//
//int main(void)
//{
//    while(cin >> n >> w){
//        memset(num,0,sizeof(num));
//        flag = 0;
//        for(int i = 1; i <= n; i++){
//            num[i].i = i;
//            scanf("%d",&num[i].x);
//        }
//        sort(num+1,num+1+n,cmp1);
//        dfs(1,0,0);
//       // getchar();
//        sort(num+1,num+1+n,cmp2);
//        if(flag!=1) {printf("-1\n");continue;}
//        printf("%d",num[1].y-1);
//        for(int i = 2; i <= n; i++) printf(" %d",num[i].y-1);
//        printf("\n");
//    }
//    return 0;
//}

/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 110;

int n, w;
int a[MAXN], b[MAXN], c[MAXN];

bool cmp(int x, int y){
    return (b[x] > b[y]);
}

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n >> w;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        b[i] = a[i] / 2;
        w -= a[i] / 2;
        c[i] = i;
    }
    if (w < 0){
        cout << -1;
        return 0;
    }
    while (w >= n){
        for (int i = 1; i <= n; ++i)
            if (b[i] < a[i])
                ++b[i], --w;
    }
    sort (c + 1, c + n + 1, cmp);
    for (int i = 1; i <= n && w > 0; ++i)
        --w, ++b[c[i]];
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (a[i] > a[j] && b[i] < b[j]){
                cout << -1;
                return 0;
            }
    for (int i = 1; i <= n; ++i)
        cout << b[i] << " ";
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%I64d",&x); return x;}

int n, w;
int cost[N], arr[N];

struct Info{
    int x, id;
}inp[N];

bool As(Info A, Info B){
    return A.x < B.x;
}

int main(){
    n = in(); w = in();
    for(int i = 1; i <= n; i++){
        inp[i].x = in();
        inp[i].id = i;
    }

    sort(inp + 1, inp + n + 1, As);

    for(int i = 1; i <= n; i++){
        cost[i] = (inp[i].x + 1) / 2;
    }

    int i = 1, j = 1;
    while(i <= n){
        while(inp[i].x == inp[i + 1].x && (i + 1) <= n){
            i++;
        }
        if(i == n) break;
        for(j = i + 1; j <= n; j++){
            if(cost[j] > cost[i]) break;
            if(cost[j] == cost[i]){
                cost[j]++;
            }
        }
        i++;
    }

    int ans = 0;
    for(i = 1; i <= n; i++){
        ans += cost[i];
        arr[inp[i].id] = cost[i];
    }

    if(ans > w) puts("-1");
    else {
        int rem = w - ans, c = n;
        while(rem > 0 && c > 0){
            int d = inp[c].x - cost[c];
            if(d >= rem){
                arr[inp[c].id] += rem;
                rem = 0;
            }else {
                arr[inp[i].id] += d;
                rem -= d;
            }
            c--;
        }
        if(rem != 0) puts("-1");
        else for(i = 1; i <= n; i++){
            printf("%d%c",arr[i],(i == n ? '\n' : ' '));
        }
    }
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
long long arr[10055];
long long brr[10055];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	long long n;
	long long x;
	long long sum = 0;
	long long sum2=0;
	cin >> n;
	cin >> x;
	for (size_t i = 0; i < n; i++)
	{
		cin >> arr[i];
		sum2 += arr[i];
		if (arr[i] > 1)
		{
			brr[i] = arr[i] / 2;
			sum += brr[i];
		}
		else
			continue;
	}
	if (sum > x)
		cout << "-1";
	else
	{
		if (sum2 == x)
		{
			for (size_t i = 0; i < n; i++)
			{
				cout << arr[i] << " ";
			}
		}
		else
		{
			x = x - sum;
			while (x > 0)
			{
				for (int i = 0; i < n; i++)
				{
					if (x > 0)
					{
						brr[i] = brr[i] + 1;
						x--;
					}
					else
					{
						break;
					}
				}
			}
			for (size_t i = 0; i < n; i++)
			{
				cout << brr[i] << " ";
			}
		}
	}
	return 0;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define endl "\n"
#define ctvl(a, v) {auto b = &a[0]; fill_n(b, sizeof(a)/sizeof(*b), v);}
#define ctvl2(a, v) {auto b = &a[0][0]; fill_n(b, sizeof(a)/sizeof(*b), v);}
#define SZ(x) ((int)(x).size())
#define pb  push_back
#define nosync { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define int long long

void soln();
signed main(){
    int t = 1;
    // nosync
    // cin >> t;
    while(t--) soln();
    return 0;
}

int cc(int a, int b) {
    return a / b + !!(a % b);
}
#define RIS return *this
#define TTT template<typename T>
#define TAB template<typename A, typename... B>
#define ENI(x) typename enable_if<sizeof(dud<T>(0)) x 1, dbg&>::type operator<<(const T& v)
#define SOP dbg& operator<<
TTT auto dud(T* x) -> decltype(cerr << *x, 0);
TTT char dud(...);
struct dbg{
    TTT ENI(!=) { cerr << boolalpha << v; RIS; }
    TAB SOP(const pair<A, B...>& d){ RIS << "(" << d.first << ", " << d.second << ")";}
    TTT ENI(==) {
        *this << "{"; string sep;
        for(auto& it : v) { *this <<  sep << it, sep = ", "; }
        RIS << "}";
    }
    TAB void out(const A& v, const B&... tail){*this << v << " "; out(tail...);}
    void out(){}
};
#ifdef LOCAL
#define imie(...) printf("#%d:<%s> = ", __LINE__, #__VA_ARGS__), dbg().out(__VA_ARGS__), printf("\n");
#else
#define imie(...) 9;
#endif

void soln() {
    int n, w;
    cin >> n >> w;
    vector<int> A(n), C(n);
    for (int i = 0; i < n; ++i) cin >> A[i], C[i] = A[i];
    sort(A.begin(), A.end());
    vector<int> B(n, 0);
    B[0] = cc(A[0], 2);
    for (int i = 0, j; i < n;) {
        j = i;
        while (j < n and A[i] == A[j]) { B[j++] = B[i]; }
        if (j != n) B[j] = max(cc(A[j], 2), B[i] + 1);

        i = j;
    }
    map<int, int> D;
    int sum = 0;
    for (int i = 0; i < n; ++i) D[A[i]] = B[i], sum += B[i];
    for (int i = 0; i < n; ++i) { C[i] = D[C[i]]; }
    if(sum > w){
        cout << -1 << endl;
    }
    else{
        for(int i = 0; i < n; ++i){
            if(C[i] == B[n-1]){
                C[i] += w - sum;
                break;
            }
        }
        for(int i = 0; i < n; ++i){
            cout << C[i] << " ";
        }
        cout << endl;
    }
}

    #include<bits/stdc++.h>
    using namespace std;
    #define ll           long long
    #define rep(i,j,n)   for(ll i=j;i<n;i++)
    #define scn(a)       scanf("%lld",&a)
    #define scnl(a,b)      scanf("%lld %lld",&a,&b)
    #define nl              printf("\n")
    #define prnt(a)     printf("%lld",a)
    #define tc           ll t; scn(t); while(t--)
    #define inp          scn(n); rep(i,0,n) scn(a[i])
    #define vec          vector<ll>
    #define pb           push_back
    #define pairs        pair<ll,ll>
    #define F            first
    #define S          second
    #define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
    #define LCM(x,y) (((x)/gcd((x),(y)))*(y))
    #define POPCOUNT __builtin_popcountll
    typedef pair < int, int > pii;
    typedef pair   <ll,ll > pll;

    #define all(v)       v.begin(),v.end()
    #define srt(v)       sort(v.begin(),v.end())
    #define srtr(v)      sort(v.rbegin(),v.rend())
    #define mem(a)       memset(a,0,sizeof(a))
    #define im           int main()
    #define maxx         200005
    #define inf          INT_MAX
    #define zer          INT_MIN
    #define pq            priority_queue<ll>
    #define pqmn       priority_queue<ll,vector<ll>,greater<ll>>
    #define oto       for(auto itr=v.begin();itr!=v.end();itr++)
    #define otor       for(auto itr=v.rbegin();itr!=v.rend();itr++)

    #define fstt         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll mod=1e9+7;

    //int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
    //int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
    //int dir8[8][2] = {{-1,0},{0,1},{1,0},{0,-1},{-1,-1},{1,1},{1,-1},{-1,1}};ll mod=1e9+7;
       ll m,l,r,n,q,j,i,cr,cl,c,cnt,k;
     ll ar[maxx];
     ll br[maxx];
    int kaj=2e6+5;

    // unordered_map<ll,ll> mp,pos;
     int arr[maxx];

     bool cmp(pairs a, pairs b)
     {

         return a.F>b.F;
     }

    im
    {
      ll w;
      scnl(n,w);

      ll sm=0;
      ll hr=0;
      vector<pairs> v;
      map<ll,ll> mp;
      ll lf=w;

      for(i=0;i<n;i++)
      {
          cin>>ar[i];
          sm+=ar[i];
          v.pb({(ar[i]+1)/2,i});

          mp[i]=(ar[i]+1)/2;
          lf-=mp[i];
      }

      if(lf<0)
        {
            //cout<<"Raju\n";
         cout<<"-1";
         return 0;
        }

      //ll lf=w-hr;

      sort(v.begin(),v.end(),cmp);

//      for(i=0;i<v.size();i++)
//          cout<<v[i].F<<" ";
//          nl;
//
//        cout<<lf;
//        nl;
      for(i=0;i<v.size();i++)
      {

          if(ar[v[i].S]-v[i].F<=lf)
          {
              mp[v[i].S]+=(ar[v[i].S]-v[i].F);
              lf-= (ar[v[i].S]-v[i].F);
          }

          else
          {
              mp[v[i].S]+=lf;
              break;
          }

      }

             rep(i,0,n)
             cout<<mp[i]<<" ";

    }

#include<iostream>
using namespace std;

typedef struct tea
{
int capacite;
int contenue;
int verif;
}tee;

void tri(tee table[], int n,int* a){
int i, tmp, permutation = 1;
tee tmpe;
while (permutation == 1){
permutation = 0;
for (i=0; i<n-1; i++)
if (table[i].capacite < table[i+1].capacite){
tmpe = table[i];
table[i] = table[i+1];
table[i+1] = tmpe;
tmp = a[i];
a[i] = a[i+1];
a[i+1] = tmp;
/* Il y a eu permutation */
permutation = 1;
} /* if */
} /* while */
}

int main()
{
int n,w,s=0,i,test=1;
cin >> n >> w;
tee *t=new tee[n];
int *a=new int[n];
for (i=0;i<n;i++)
{
cin >> t[i].capacite ;
s=s+t[i].capacite;
t[i].contenue=0;
a[i]=i;
}
if (s<w)
{
cout << -1;
return 1;
}
tri(t,n,a);
if (n==1)
{
if (t[0].capacite>=w) cout 	<< w;
else cout << -1;
return 0;
}

for (i=0;i<n;i++)
{
t[i].contenue=(t[i].capacite+1)/2;
w=w-t[i].contenue;
}
if (w<0)
{
cout << -1;
return 0;
}
while (w)
{
for (i=0;i<n && w;i++)
{
if (t[i].contenue<t[i].capacite)
{
t[i].contenue++;
w--;
}
}
}
for (i=0;i<n;i++) cout << t[a[i]].contenue << ' ' ;
}

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,w,a[150],a1[150],s=0;
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==1)
		 a[i]=(a[i]+1)/2;
		else a[i]=a[i]/2;
	}
	if(s>w)
	{
		cout<<"-1";
		return 0;
	}
	for(int i=0;s!=w;i++)
	{
		if(a[i]-a1[i]+s>=w)
		{
			a1[i]+=(w-s);
			s=w;
		}
		else
		{
			a1[i]=a[i];
			s+=(a[i]-a1[i]);
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<a1[i]<<" ";
	}
	return 0;
}

                    /*"Success isn't permanent, failure isn't fatal,
                                          it's the courage to continue that counts"*/

#include <bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb(x)           push_back(x)
#define mp              make_pair
#define sz(x)           x.size()
#define mem(x ,y)       memset(x , y , sizeof x )
#define all(a )         a.begin() , a.end()
#define endl            "\n"
#define pii             pair<int,int>
#define clr(x)          x.clear()
#define sl(x )          scanf("%I64d" ,&x)
#define si(x )          scanf("%d" ,&x)
#define forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define rep(i,n )       for(int i= 0; i<n ; i++ )
#define repi(i,n )      for(int i= 1; i<=n ; i++ )
#define repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
typedef long long ll  ;
ll mod1 =  1e9+7, mod2 = 998244353 ;
ll  mod  =  mod1 ;
typedef unsigned long long  ull ;
int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }
template < typename T > T mul(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T sub(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return ((x-y)%mod+mod )%mod;  }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}
template<class T> string to_str(T t){stringstream ss; ss<<t; return ss.str();}
template < typename T >
T  bigmod(T x, T k ,T mod = mod) {
    if(k == 0 ) return (T)1;
    if(k&1  ) {
        return ( (x%mod)*bigmod(x,k-1, mod )%mod )%mod ;
    } else {
        T ret = bigmod(x,k/2  , mod ) ;
        ret %= mod ;
        return (ret*ret )%mod;
    }

}
template < typename T >
T  invmod( T x , T m) {
    return bigmod(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree< int   ,     // change type
//               null_type,
//               less_equal  < int >  ,  // change type ..
//               rb_tree_tag,
//               tree_order_statistics_node_update> o_set;
// less for set and  less_equal  for multiset
// order_of_key (k) : Number of items strictly smaller than k
// find_by_order(k) : K-th element in a set (counting from zero) returns iterator
// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ ";
        for(int i=0;i < n ; i++ )
            cerr<<a[i]<<' ' ;
                cerr<< " ]" <<  endl;
}
template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ ";
        for(int i=0; i<sz(v) ; i++ )
            os << v[i] << ' ' ;
                return os << " ]\n" ;
}
template < typename T >
ostream &operator << ( ostream & os, const map< T ,T> &Map  ) {
    os << "[ ";
        repit(it , Map )
            os << "[" <<(*it).ff << ' ' << (*it).ss << "] "    ;
                return os << "]\n" ;
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &Set  ) {
    os << "[ ";
        repit(it , Set )
            os <<  *it  << ' ' ;
                return os << " ]\n" ;
}
// int dx[] = {0 , 0 ,+1, -1 } ;
// int dy[] = {-1, +1,0 , 0 };
// int dx[ 10 ] =  {-2,-2, 2, 2  ,+ 1, -1  , +1, -1 }  ;
// int dy[ 10 ] =  {+1,-1, 1, -1 , +2,+2 , -2,-2  }  ;
const int maxn  = (int )2e5+123 ;
const int inf  =  1e9 ;
#define  int  ll
///////////////////////////////////////////////////////////////

int a[maxn] , b[maxn ] ;
void solve()  {
    int n ,ans = 0 , x, y , c ,w  ;
    cin >> n >> w;
    rep(i,n ) cin>>a[i] ;
    sort(a ,a+n )  ; reverse(a,a+n) ;
    rep(i, n ) {
        if(w < a[i]/2+ (a[i]%2!=0) )  {cout<<-1 ; return ; }
        w -=  a[i]/2+ (a[i]%2!=0);
        b[i ]  =  a[i]/2+ (a[i]&1) ;
        // dbg(i , a[i]  ,b[i] , w ) ;
    }

    rep(i ,n ) {
        if(w>0) {

            b[i] +=  min(a[i]-b[i] , w)  ;
            w -= min(a[i]-b[i] ,w) ;
            // dbg(i , b[i] );
        }

    }

    rep(i,n ) cout << b[i] << ' ' ;
    cout <<endl ;
}
signed main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
          // freopen("out.txt", "w", stdout);
    #endif
    ios :: sync_with_stdio(false);  cin.tie(0);
    cout.tie(0) ;
    clock_t st = clock() ;
    // cout << fixed << setprecision(12) ;
    int  c = 0 ,t = 1 ;
    // cin>>t ;
    while(t--) {
        solve()  ;
    }
    // cerr <<   "Execution time : " << (double  )  (clock()-st )/CLOCKS_PER_SEC << endl ;

    return 0 ;

}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<set>

using namespace std;

#define ii pair<int, int>
#define mp make_pair
#define ll long long
#define pp push_back
#define PI (long double)(3.14159265358979323846)

bool compSecond(ii x, ii y)
{
	return x.second < y.second;
}

int n, potVolume;
ii cupVolume[101];
int filling[101];

int main()
{
	//freopen("input.in", "r", stdin);
	while (cin >> n >> potVolume)
	{
		for (int i = 0; i < n; i++)
		{
			cin >> cupVolume[i].second;
			cupVolume[i].first = i;
		}

		sort(cupVolume, cupVolume + n, compSecond);
		for (int i = 0; i < n; i++)
		{
			if (!i)
			{
				filling[cupVolume[i].first] = (cupVolume[i].second + 1) / 2;
			}
			else
			{
				if (cupVolume[i].second == cupVolume[i - 1].second)
					filling[cupVolume[i].first] = filling[cupVolume[i - 1].first];
				else
					filling[cupVolume[i].first] = filling[cupVolume[i - 1].first] + 1;
			}

			if (filling[cupVolume[i].first] > cupVolume[i].second)
			{
				potVolume = -1;
				break;
			}

			potVolume -= filling[cupVolume[i].first];
			if (potVolume < 0)
				break;
		}

		if (potVolume > 0)
		{
			for (int i = n - 1; i >= 0; i--)
			{
				int temp = min(potVolume, cupVolume[i].second - filling[cupVolume[i].first]);
				filling[cupVolume[i].first] += temp;
				potVolume -= temp;
				if (!potVolume)
					break;
			}
		}

		if (potVolume != 0)
			cout << -1 << endl;
		else
		{
			sort(cupVolume, cupVolume + n);
			for (int i = 0; i < n; i++)
			{
				if (i)
					cout << " ";
				cout << filling[cupVolume[i].first];
			}
			cout << endl;
		}

	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i>=b;i--)
#define s(a) scanf("%d",&a)
#define clr(a,t) memset(a,0,sizeof a)

int main()
{
	int n,w;
	s(n),s(w);
	int a[n],b[n];
	int flag=0;
	clr(a,0),clr(b,0);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	{
		b[i]=(a[i]+1)/2;
		w-=b[i];
		if(w<0)
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	int i=n-1;
	while(w>0)
	{
		int t=a[i]-b[i];
		if(t<=w)
		{
			b[i]+=t;
			w-=t;
		}
		else
		{
			b[i]+=w;
			break;
		}
		i--;
	}
	for(int i=0;i<n;i++)
		cout<<b[i]<<" ";
	cout<<endl;
}

#include<bits/stdc++.h>
using namespace std;
long long n,m,k,ans,sum,i,j,a[1000009],b[1000009];
double x;
int main()
{
 	cin>>n>>k;
 	for(i=1;i<=n;i++)
 	cin>>a[i];
 sort(a+1,a+1+n);
 for(i=1;i<=n;i++)
 {
     if(k<0){cout<<"-1"<<endl;return 0;}
     k-=(a[i]+1)/2;
     b[i]=(a[i]+1)/2;
 }

 if(a[n]<k){cout<<"-1"<<endl;return 0;}
 else
 b[n]+=k;
 for(i=1;i<=n;i++)
 cout<<b[i]<<" ";
					 return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
  int n, w; cin >> n >> w;
  int A[n], B[n];
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> A[i];
    B[i] = (A[i] + 1) / 2;
    sum += B[i];

  }
  if(sum > w){
    cout << -1;
  }
  else{
    sum = 0;
    int mx = 0;
    for(int i = n - 1; i >= 0; i--){
      if(mx < B[i]){
        mx = B[i];
      }
      else{
        B[i] = mx;
      }
      sum += B[i];
    }
    for(int i = 0; i < n; i++){
      if(A[i] < B[i]){
        sum = w + 1;
        break;
      }
    }
    if(sum > w){
      cout << -1;
    }
    else{
      mx = A[0];
      for(int i = 0; i < n; i++){
        mx = min(mx, A[i]);
        int tmp = min(w - sum, mx - B[i]);
        B[i] += tmp;
        mx = B[i];
        sum += tmp;
      }

      for(int i = 0; i < n; i++){
        cout << B[i] << " ";
      }
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD           1000000007
#define forn(i,s,n)   for(int i = s ; i < n ; i++)
#define mp            make_pair
#define pb            push_back
#define st            first
#define nd            second
#define sz(v)         ((int)((v).size()))
const int SIZE=50005;
const int OO = (int)1e9;
const double PI = acos(-1);
typedef vector<int> vi;
typedef long long int ll;
typedef pair<int , int > ii;
typedef pair<double , double > Point;
typedef pair<pair<int, double> , int > iii;
ll ans = 0 , f =0;
map<int , int > mpp;
int arr[SIZE];
int A[SIZE];
int main(){
int N , W ;
scanf("%d %d", &N , &W);
forn(i , 0 , N){
     scanf("%d" , &arr[i]);

}

int mx = arr[0] , mxi = 0;
forn(i , 0 , N){
     A[i]=arr[i]/2 , W-=arr[i]/2;
     if(arr[i]%2)A[i]++ , W--;
     if(arr[i]>mx){
          mx = arr[i];
          mxi = i;
     }
}

if(W<0){

     puts("-1") ;
return 0;
}
A[mxi]+=W;
forn(i , 0 , N){
     if(i==mxi)continue;
     if(A[i]==A[mxi] && arr[i]!=arr[mxi]){
          puts("-1") ;
return 0;
     }
}

     forn(i , 0 , N)printf("%d " , A[i]);

}