intcheck(int p) { int l = 1, r = n; while (l <= r) { int mid = (l + r) >> 1; int s = mid, now = p, res1 = 1, res2 = 1; for (int i = s - 1; i >= 1; i --) { if (a[s] - a[i] > now) { if (s == i + 1) {res1 = 0; break;} else {s = i + 1, now = 2 * now / 3, ++ i;} } } s = mid, now = p; for (int i = s + 1; i <= n; i ++) { if (a[i] - a[s] > now) { if (s == i - 1) {res2 = 0; break;} else {s = i - 1, now = 2 * now / 3, -- i;} } }
if (res1 && res2) returntrue; if (! res1 &&! res2) returnfalse; if (! res1) r = mid - 1; else l = mid + 1; } returnfalse; }
intmain() { n = read(); for (int i = 1; i <= n; i ++) a[i] = read();
sort(a + 1, a + n + 1);
int l = 0, r = a[n];
while (l < r) { int mid = (l + r) >> 1; if (check(mid)) r = mid; else l = mid + 1; } printf("%d", l); return0; }