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. CSS效果篇--纯CSS+HTML实现checkbox的思路与实例

    checkbox应该是一个比较常用的html功能了,不过浏览器自带的checkbox往往样式不怎么好看,而且不同浏览器效果也不一样.出于美化和统一视觉效果的需求,checkbox的自定义就被提出来了. ...

  2. 1.打开windows中功能的快捷方式

    1.打开组策略 命令:gpedit.msc 2.打开注册表 命令:regedit 3.快速打开本地安全组策略 命令:secpol.msc 4.打开服务 命令:services.msc 5.系统退域的时 ...

  3. 埋点(Event Tracking)vs 无埋点(Codeless Tracking) vs 可视化埋点(Visual Event Tracking)

    在理解什么是埋点之前,首先需要了解一些基础知识:(以下摘自:http://www.chinawebanalytics.cn/auto-event-tracking-good-bad-ugly/) 我们 ...

  4. MFC 标签页Tab Control

    自带的标签页不好用,因此借助了TabSheet文件TabSheet源码 1.在解决方案资源管理器——项目处鼠标右键——在文件资源管理器中打开文件夹(或者按下图,更方便),把TabSheet.h.Tab ...

  5. 顺序表应用1:多余元素删除之移位算法(SDUT 3324)

    Problem Description 一个长度不超过10000数据的顺序表,可能存在着一些值相同的"多余"数据元素(类型为整型),编写一个程序将"多余"的数据 ...

  6. [Shell] 分隔字符串为数组

    #!/bin/bash tmp="test,girl,boy,love" OLD_IFS="$IFS" IFS="," arr=($a) I ...

  7. 小程序和vue的区别

    最近开发了一个比较完整的小程序项目,打算总结一下,小程序开发和vue开发的代码上的区别 1.小程序的路由写在app.json文件里,vue写在route.js里 2.小程序用 src="{{ ...

  8. IDEA checkout Git 分支 弹出 Git Checkout Problem

    1. 本地分支切换的时候(例如A切到B),会弹出来Restore workspace on branch switching 对话框,如果选择是的话,在切换分支的时候,你在当前分支(A)所做的一些还未 ...

  9. 2018-2019-2 20175227张雪莹《Java程序设计》实验四 《Android程序设计》

    2018-2019-2 20175227张雪莹<Java程序设计> 实验四 <Android程序设计> 实验报告封面 课程:Java程序设计 班级:1752班 姓名:张雪莹 学 ...

  10. Nginx-HTTP之listen指令解析

    1. ngx_http_core_listen static char * ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void ...