#include <cstdio>
#include <algorithm>
#define MAXN 1000100
#define LL long long
#define RE register
using namespace std;
LL a[MAXN];
inline LL read() {
LL x = 0;
char c = getchar();
while (c < '0' || c > '9') {
c = getchar();
}
while ('0' <= c && c <= '9') {
x = (x << 3) + (x << 1) + (c ^ 0x30);
c = getchar();
}
return x;
}
int main() {
LL N = read();
LL M = read();
LL right = 0;
for (RE LL i = 0; i < N; ++i) {
a[i] = read();
right = a[i] > right ? a[i] : right;
}
LL left = 0;
while (left <= right) {
LL mid = (left