• محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Sara wants to hold a birthday party for her niece. In this ceremony, the guests form a circle around the niece and cheer her up. But the problem is that the heights of the guests present at the birthday party is very different. Therefore, if these guests are randomly placed in the circle, due to the difference in height, they may not be able to hold each other’s hands and form the ring. The desired arrangement is a circular arrangement of guests in which the maximum height difference between consecutive individuals is minimum (there may be more than one desired arrangement). For example, if the heights of guests are 3,2,2,4,3,13,2,2,4,3,1, one desired arrangement could be as follows, where the maximum height difference between consecutive individuals is 11.

توضیح تصویر

By receiving the heights of guests, calculate the maximum height difference between consecutive individuals in a desired arrangement.

ورودی

The first line of the input contains an integer nn (2n105)(2 \leq n \leq 10^5), which is the the number of guests. The next line contains a sequence l1,l2,...,lnl_1,l_2,...,l_n of nn integers, where lil_i (1li109)(1 \leq l_i \leq 10^9) represents the height of the ithi-th guests.

خروجی

In the only line of output, print the maximum difference in height between two consecutive individuals in a desired circular arrangement.

ورودی نمونه 1

5
2 1 1 3 2
Plain text

خروجی نمونه 1

1
Plain text

ورودی نمونه 2

3 
30 10 20
Plain text

خروجی نمونه 2

20
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.