#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int num, val, ans = INT_MAX - 101; int lower, upper; vector lst { INT_MIN + 100, INT_MAX - 100 }; vector::iterator itIn, itRef; cin >> num; while(num) { --num; cin >> val; itIn = find_if(lst.begin(), lst.end(), [=](int l){ return val < l; }); itRef = lst.insert(itIn, val); lower = *(itRef + 0) - *(itRef - 1); upper = *(itRef + 1) - *(itRef + 0); if(lower == 0) { lst.erase(itRef); continue; } if(lower > 0) { ans = min(min(lower, upper), ans); } } cout << ans << endl; return 0; }