P18104 [COCI 2026/2027 #2] Dijamanti

Description

After Ivor acquired substantial wealth through hard work and perseverance, he decided to carefully invest in some nice diamonds. He currently owns $n$ diamonds, safely stored in his diamond box. Each diamond has its own size. The size of each diamond is an odd positive integer. ![](https://cdn.luogu.com.cn/upload/image_hosting/eolhrdoi.webp) Every time Ivor goes on a trip (which is quite often), he wants to make sure nobody messes with his diamonds while he is away. That is why he makes a sketch of his box, including all the diamonds, on a piece of paper before he leaves for a trip. When he comes back, he will compare the state of the box with the one depicted in the sketch to see if anything has changed. The diamond box is divided into $n$ compartments, each containing exactly one diamond. The diamonds are arranged in a single row, from left to right, and the size of the $i$-th diamond is given by $a_i$. In a sketch, each diamond is made up of the character `X` and has a diamond shape. Its widest row consists of exactly $a_i$ `X` characters. Starting from the widest row, each row above and below it contains two fewer `X` characters than the row immediately below or above it, respectively. The topmost and bottommost rows therefore consist of a single `X`. The compartment of the $i$-th diamond is exactly $a_i$ characters wide. The remaining spaces inside each compartment are represented by the character `*`. Each diamond is horizontally centered within its compartment. The compartments are separated by vertical borders represented by the character `|`. The left and right borders of the box are also represented by `|`, while the top and bottom borders, including the corners of the box, are represented by `-`. All compartments have the same height, determined by the largest diamond. Diamonds that are shorter are vertically centered within their compartments. Since Ivor is a very busy man, he unfortunately does not have enough time to make the sketch before he leaves tomorrow. That’s why he asked you, his friend, to help him. Will you sketch Ivor’s diamond box for him?

Input Format

The first line contains a positive integer $n$ ($1 \le n \le 100$), the number of diamonds in Ivor’s diamond box. The second line contains $n$ odd positive integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 100$), the sizes of the diamonds.

Output Format

Output the sketch of Ivor’s diamond box, following the rules described in the task statement.

Explanation/Hint

### Explanation of example 1 The box contains only one diamond, whose size is $9$. Its widest row consists of $9$ `X` characters, and each row above and below it contains two fewer `X` characters than the previous row. ### Explanation of example 2 The largest diamond has size $5$, so the box is $5$ rows tall. The diamonds of sizes $3$ and $1$ are vertically centered within their compartments, while all diamonds are horizontally centered. ### Scoring | Subtask | Points | Constraints | | --- | ---: | --- | | 1 | 15 | $n = 1$. | | 2 | 9 | $a_i = 1$ or $a_i = 3$ for every $i = 1, 2, \ldots, n$. | | 3 | 6 | $a_1 = a_2 = \cdots = a_n$. | | 4 | 20 | No additional constraints. |