Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;     

const int MAXN = 228;

const ll MOD = 1e9 + 7;
const ll REV2 = (MOD + 1) / 2;

using Vec = vector<ll>;

ll p2(ll a) {
    if (!a) {
        return 1;
    }

    ll v = p2(a / 2);
    v = (v * v) % MOD;

    if (a & 1) {
        v = (v * 2) % MOD;
    }

    return v;
}


const ll INF = (1ll << 60);

ll eval(const Vec& a) {
    assert(a.size());

    ll mn = INF;
    for (ll x : a) {
        mn = min(mn, x);
    }

    ll cn = p2(mn) - 1;
    Vec na(a);
    for (ll& x : na) {
        x -= mn;
    }

    ll pv = 0;
    ll p = 0;

    na.push_back(0);

    for (ll x : na) {
        p += max(x - pv, 0ll);
        pv = x;
    }

    ll ans = p2(p) * cn % MOD;
    Vec cur;
    
    ll ansgood = REV2 * REV2 % MOD;

    for (ll x : na) {
        if (!x) {
            ansgood = (ansgood * 2) % MOD;
            if (!cur.empty()) {
                ansgood = ansgood * eval(cur) * 2 % MOD;
                cur.clear();
            }
        } else {
            cur.push_back(x);
        }
    }
    
    return (ans + ansgood) % MOD;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    Vec a(n);
    for (ll& x : a) {
        cin >> x;
        --x;
    }

    ll ans = eval(a);
    cout << (ans * 2) % MOD << "\n";
}

Compiler output:
a.cc: In function 'll eval(const Vec&)':
a.cc:55:17: error: no matching function for call to 'max(ll, long long int)'
   55 |         p += max(x - pv, 0ll);
      |              ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:55:17: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   55 |         p += max(x - pv, 0ll);
      |              ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:55:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   55 |         p += max(x - pv, 0ll);
      |              ~~~^~~~~~~~~~~~~