#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
int n,m;
cin >> n >> m;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a,a + n);
A: if (a[0] == 0) {cout << (a[n - 1] + 2) * pow(2,(n - 1)); return 0;}
// 上述代码,我觉得只要最小值是0,那么只需要看最大值就可以了,以上是我认为的最大方法。
else
{
a[0] -= 2;
if (a[0] < 0) {cout << a[0] * pow(2,(n - 1)); return 0;}
else if (a[0] > 1) {cout << a[0] / (int)pow(2,(n - 1)); return 0;}
else goto A;
}
return 0;
}