//qoj4
#include <bits/stdc++.h>
using namespace std;
#include "gap.h"
long long findGap(int T, int n){
static long long a[100010];
memset(a, 0, sizeof(a));
if(T == 1){
a[0] = -3, a[n+1] = 2e18;
for(int i = 1, j = n; i <= j; ++ i, -- j){
MinMax(a[i-1] + 1, a[j+1] - 1, &a[i], &a[j]);
}
long long mx = 0;
for(int i = 1; i < n; ++ i){
mx = max(mx, a[i+1] - a[i]);
}
return mx;
} else {
long long mn, mx;
MinMax(-3, 2e18, &mn, &mx);
long long k = (mx - mn - 1) / (n - 1) + 1;
int cnt = 0;
a[++cnt] = mn;
a[++cnt] = mx;
for(long long i = mn; i <= mx; i += k){
long long tx, ty;
MinMax(i, min(i+k-1, mx), &tx, &ty);
a[++cnt] = tx;
a[++cnt] = ty;
}
sort(a + 1, a + cnt + 1);
long long mx = 0;
for(int i = 1; i < cnt; ++ i){
mx = max(mx, a[i+1] - a[i]);
}
return mx;
}
}