The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.

Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all the houses with larger numbers. In other words, a house is luxurious if the number of floors in it is strictly greater than in all the houses, which are located to the right from it. In this task it is assumed that the heights of floors in the houses are the same.

The new architect is interested in n questions, i-th of them is about the following: "how many floors should be added to the i-th house to make it luxurious?" (for all ifrom 1 to n, inclusive). You need to help him cope with this task.

Note that all these questions are independent from each other — the answer to the question for house i does not affect other answers (i.e., the floors to the houses are not actually added).

Input

The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland.

The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.

Output

Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero.

All houses are numbered from left to right, starting from one.

Example

Input
5
1 2 3 1 2
Output
3 2 0 2 0 
Input
4
3 2 1 4
Output
2 3 4 0 
 #include<bits/stdc++.h>
using namespace std;
int n;
long long int num[],maxn;
int main()
{
while(~scanf("%d",&n))
{
for(int i = ; i < n; i++)
scanf("%lld",&num[i]); maxn = num[n-];
num[n-] = ;
for(int i = n-; i >= ; i--)
{
if(num[i] <= maxn)
{
num[i] = maxn - num[i] + ;
}
else
{
maxn = num[i];
num[i] = ;
}
}
for(int i = ; i < n; i++)
{
printf("%lld",num[i]);
if(i!=n-) printf(" ");
}
printf("\n");
}
return ;
}

最新文章

  1. WPF menu
  2. php emoji处理微信表情
  3. leetcode解题:Add binary问题
  4. 【通信框架】Apache的开源通信框架thrift概述
  5. POJ3279 Catch That Cow(BFS)
  6. MVC5模板部署到mono
  7. WPF 圆角输入框
  8. Java Script 读书笔记 (三) 函数
  9. Java Spring MVC框架搭建(一)
  10. Ajax配合vue+element打造个人专属loading
  11. Finance财务软件帮助
  12. 细说SpringDI Setter注入
  13. BZOJ3211 花神游历各国 并查集 树状数组
  14. [工具类] 读取解析json文件
  15. 解决React Native使用Fetch API请求网络报Network request failed
  16. hadoop balance工具平衡集群dfs存储及遇到异常Got error, status message Not able to receive block 1073959989 from /192.168.1.37:3004 because threads quota is exceeded
  17. 危机边缘第五季/全集Fringe迅雷下载
  18. iOS9 Error Domain=NSURLErrorDomain Code=-1022 App Transport Security (ATS)
  19. 一个不需要Log4Net的写日志的简单方法
  20. 牛掰的python与unix

热门文章

  1. 分享java常用技术教程:dubbo、zookeeper、ActiveMq、多线程、Redis、PowerDesigner等
  2. ORA-09925: Unable to create audit trail file带来的sqlplus / as sysdba无法连接
  3. jQuery系列 第六章 jQuery框架事件处理
  4. php Redis函数使用总结(string,hash,list, set , sort set )
  5. 开发一款APP所需要的时间
  6. VueJs 源码解析 (四) initRender.Js
  7. [LeetCode] Minimum Time Difference 最短时间差
  8. 报错django.db.migrations.exceptions.InconsistentMigrationHistory
  9. 使用Remix编译和部署以太坊智能合约
  10. 手动导入xmpp后,再使用cocoapods的时候出现的问题