Danang and Darto are classmates. They are given homework to create a permutation of N integers from 1 to N. Danang has completed the homework and created a permutation A of N integers. Darto wants to copy Danang's homework, but Danang asks Darto to change it up a bit so it does not look obvious that Darto copied.

The difference of two permutations of N integers A and B, denoted by diff(A,B), is the sum of the absolute difference of Ai and Bi for all i. In other words, diff(A,B)=ΣNi=1|Ai−Bi|. Darto would like to create a permutation of N integers that maximizes its difference with A. Formally, he wants to find a permutation of N integers Bmax such that diff(A,Bmax)≥diff(A,B′) for all permutation of N integers B′.

Darto needs your help! Since the teacher giving the homework is lenient, any permutation of N integers B is considered different with A if the difference of A and B is at least N. Therefore, you are allowed to return any permutation of N integers B such that diff(A,B)≥N.

Of course, you can still return Bmax if you want, since it can be proven that diff(A,Bmax)≥N for any permutation A and N>1. This also proves that there exists a solution for any permutation of N integers A. If there is more than one valid solution, you can output any of them.

Input

Input begins with a line containing an integer: N (2≤N≤100000) representing the size of Danang's permutation. The next line contains N integers: Ai (1≤Ai≤N) representing Danang's permutation. It is guaranteed that all elements in A are distinct.

Output

Output in a line N integers (each separated by a single space) representing the permutation of N integers B such that diff(A,B)≥N. As a reminder, all elements in the permutation must be between 1 to N and distinct.

Examples

input

4
1 3 2 4
output

4 2 3 1
input

2
2 1
output

1 2
Note

Explanation for the sample input/output #1

With A=[1,3,2,4] and B=[4,2,3,1], diff(A,B)=|1−4|+|3−2|+|2−3|+|4−1|=3+1+1+3=8. Since 8≥4, [4,2,3,1] is one of the valid output for this sample.

解题思路j:题目要求的是将数组元素重新排列,使得对应位置上的元素相减和的绝对值最大,即保证最大程度每一位上的元素都不同,将第一位对应最后一位,第二位对应倒数第二位,...。

AC代码:

#include <iostream>
using namespace std;
int main()
{
int n,a;
while(cin>>n)
{
for(int i=;i<=n;i++)
{
cin>>a;
cout<<n-a+<<" ";
}
cout<<endl;
}
return ;
}

2019-2020 ICPC, Asia Jakarta Regional Contest A. Copying Homework的更多相关文章

  1. 2019-2020 ICPC, Asia Jakarta Regional Contest A. Copying Homework (思维)

    Danang and Darto are classmates. They are given homework to create a permutation of N integers from  ...

  2. 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)

    2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...

  3. 2019-2020 ICPC, Asia Jakarta Regional Contest

    目录 Contest Info Solutions A. Copying Homework C. Even Path E. Songwriter G. Performance Review H. Tw ...

  4. 2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings

    As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC ...

  5. 2018 ICPC Asia Jakarta Regional Contest

    题目传送门 题号 A B C D E F G H I J K L 状态 Ο . . Ο . . Ø Ø Ø Ø . Ο Ο:当场 Ø:已补 .  :  待补 A. Edit Distance Thin ...

  6. 2019-2020 ICPC, Asia Jakarta Regional Contest C. Even Path

    Pathfinding is a task of finding a route between two points. It often appears in many problems. For ...

  7. 模拟赛小结:2019-2020 ICPC, Asia Jakarta Regional Contest

    比赛链接:传送门 离金最近的一次?,lh大佬carry场. Problem A. Copying Homework 00:17(+) Solved by Dancepted 签到,读题有点慢了.而且配 ...

  8. 2019-2020 ICPC, Asia Jakarta Regional Contest C. Even Path(思维)

    Pathfinding is a task of finding a route between two points. It often appears in many problems. For ...

  9. Asia Jakarta Regional Contest 2019 I - Mission Possible

    cf的地址 因为校强, "咕咕十段"队获得了EC-final的参赛资格 因为我弱, "咕咕十段"队现在银面很大 于是咕咕十段决定进行训练. 周末vp了一场, 这 ...

随机推荐

  1. javascript 常用的一些原生方法

    一丶javascript------ reduce() reduce()方法: arr.reduce(function(prev,cur,index,arr){ ... }, init); 参数解释: ...

  2. Ubuntu14版桌面突然卡住怎么办

    参考:https://blog.csdn.net/hautxuhaihu/article/details/78924926 (1)ctrl+alt+f1...6进入命令行终端.用户名,密码登录. (2 ...

  3. django-session的使用---文件session型

    3.文件Session a. 配置 settings.py       SESSION_ENGINE = 'django.contrib.sessions.backends.file'    # 引擎 ...

  4. P2709 小B的询问——普通莫队&&模板

    普通莫队概念 莫队:莫涛队长发明的算法,尊称莫队.其实就是优化的暴力. 普通莫队只兹磁询问不支持修改,是离线的. 莫队的基本思想:就是假定我得到了一个询问区间[l,r]的答案,那么我可以在极短(通常是 ...

  5. 4、docker镜像:花卷结构、commit镜像

    1.是什么 docker images 镜像是一种轻量级.可执行的独立软件包,用来打包软件运行环境和基于运行环境开发的软件,它包含运行某个软件所需的所有内容,包括代码.运行时.库.环境变量和配置文件. ...

  6. HDU 6098 - Inversion | 2017 Multi-University Training Contest 6

    /* HDU 6098 - Inversion [ 贪心,数论 ] | 2017 Multi-University Training Contest 6 题意: 求出所有B[i] = max(A[j] ...

  7. PHP mysqli_num_fields() 函数

    mysqli_num_fields() 函数返回结果集中字段(列)的数量. 语法 mysqli_num_fields(result); 参数 描述 result 必需.规定由 mysqli_query ...

  8. ttf-mscorefonts-installer 无法安装,解决办法

    ttf-mscorefonts-installer 无法安装,解决办法 原 lieefu 发布于 2017/01/11 08:11 字数 163 阅读 1007 收藏 0 点赞 0 评论 0 面试:你 ...

  9. BZOJ 4017 小 Q 的无敌异或 ( 树状数组、区间异或和、区间异或和之和、按位计贡献思想 )

    题目链接 题意 : 中文题 分析 : 首先引入两篇写的很好的题解 题解一.题解二 听说这种和异或相关区间求和的问题都尽量按位考虑 首先第一问.按二进制位计贡献的话.那么对于第 k 位而言 其贡献 = ...

  10. Linux shell -"a-d"命令

    shell中条件判断if中的-z到-d的意思 分类:shellLinux (2006)  (0) shell中条件判断if中的-z到-d的意思  [ -a FILE ] 如果 FILE 存在则为真.  ...