#include #include using namespace std; int main() { int n, m, d[1001], i, j; cin >> n >> m; for (i = 1; i <= m; i++) cin >> d[i]; sort(d + 1, d + m + 1); int count = 0, min = 0, max = 0; for (i = 0; i <= 10000; i++) { for (j = 1; j <= m; j++) { if (d[j] == -i) { min = -i; count++; if (count == n) goto END; } else if (d[j] == i) { max = i; count++; if (count == n) goto END; break; } } } END: if (max == 0) cout << -min << endl; else if (min == 0) cout << max << endl; else cout << max - min * 2 << endl; }