A. Ehab Fails to Be Thanos

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You're given an array aa of length 2n2n. Is it possible to reorder it in such way so that the sum of the first nn elements isn't equal to the sum of the last nn elements?

Input

The first line contains an integer nn (1≤n≤10001≤n≤1000), where 2n2n is the number of elements in the array aa.

The second line contains 2n2n space-separated integers a1a1, a2a2, ……, a2na2n (1≤ai≤1061≤ai≤106) — the elements of the array aa.

Output

If there's no solution, print "-1" (without quotes). Otherwise, print a single line containing 2n2n space-separated integers. They must form a reordering of aa. You are allowed to not change the order.

Examples

input

Copy

3
1 2 2 1 3 1

output

Copy

2 1 3 1 1 2

input

Copy

1
1 1

output

Copy

-1

Note

In the first example, the first nn elements have sum 2+1+3=62+1+3=6 while the last nn elements have sum 1+1+2=41+1+2=4. The sums aren't equal.

In the second example, there's no solution.

 

解题说明:水题,先排序,判断数字是否相同,相同输出-1,否则从小到大输出即可。

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main() 
{
	int n; 
	cin >> n;
	int arr[2002];
	for (int i = 0; i < 2 * n; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr + 2 * n);
	if (arr[0] == arr[2 * n - 1]) 
	{
		cout << -1 << endl;
	}
	else 
	{
		for (int i = 0; i<2 * n; i++) 
		{
			cout << arr[i] << " ";
		}
	}
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值