欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1006A.Adjacent Replacements
Adjacent Replacements
Mishka got an integer array of length as a birthday present (what a surprise!).
Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps:
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with ;
- Replace each occurrence of in the array with .
Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers () for each as described above.
For example, for the array , the following sequence of arrays represents the algorithm:
(replace all occurrences of with ) (replace all occurrences of with ) (replace all occurrences of with ) (replace all occurrences of with ) (replace all occurrences of with ) (replace all occurrences of with ) (replace all occurrences of with ) . The later steps of the algorithm do not change the array.
Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it.
Input
The first line of the input contains one integer number () — the number of elements in Mishka's birthday present (surprisingly, an array).
The second line of the input contains integers () — the elements of the array.
Output
Print integers — , where is the final value of the -th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array . Note that you cannot change the order of elements in the array.
Note
The first example is described in the problem statement.
Samples
5
1 2 4 5 10
1 1 3 5 9
10
10000 10 50605065 1 5 89 5 999999999 60506056 1000000000
9999 9 50605065 1 5 89 5 999999999 60506055 999999999
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |