Problem1270--还原二叉树III

1270: 还原二叉树III

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 424  Solved: 291
[Submit] [Status] [Web Board] [Creator:]

Description

PIPI现在知道了一棵二叉搜索树的先序序列,你能帮PIPI还原这棵二叉树吗?

Input

第一行输入序列的长度n (0<n<100).
第二行输入二叉树的先序序列。

Output

输出二叉树的后序遍历序列。

Sample Input

6
8 5 1 7 10 12

Sample Output

1 7 5 12 10 8

Source/Category