func_code_string: #include <bits/stdc++.h>   using namespace std;   const int tinf = (int)1e9 + 7;   const long long inf = (long long)1e18 + 7;   const int N = 1e3 + 5;   int main() {     {       ios::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);     }     long long n, k;     cin >> n >> k;     long long a[n], Min = inf, Max = -inf;     for (int i = 0; i < n; i++)       cin >> a[i], Min = min(Min, a[i]), Max = max(Max, a[i]);     if (k == 1)       cout << Min;     else if (k == 2)       cout << max(a[0], a[n - 1]);     else if (k >= 3)       cout << Max;     else       cout << Min;   }   