#include #include #include #include #include #include using namespace std; const int INF = 1e9; int main() { int n; cin >> n; string str(1000001, '.'); int x; for (int i = 0; i < n; i++) { cin >> x; str[x] = 'x'; } // cout << str.substr(1, 30) << endl; int ans = INF; int pos1 = str.find('x', 0); int pos2 = str.find('x', pos1 + 1); while (pos2 != string::npos) { ans = min(ans, pos2 - pos1); pos1 = pos2; pos2 = str.find('x', pos2 + 1); } if (ans == INF) { ans = 0; } cout << ans << endl; return 0; }