#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, x = 0;
  int min = 1000;
  cin >> N >> K;
  int a[1001], m[1001];
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    if (min > a[i]) {
      while (x < N) {
        m[x] = a[i];
        x++;
      }
    }
  }
  cout << m[x] << endl;
}
