#55343: c++


yp11451267@yphs.tp.edu.tw (705-43鄭丞博)


#include <iostream>
using namespace std;

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    int M, A;
    cin >> M >> A;
    bool stop = false;
    for (int i = 0; i<M; i++)
    {
        int tmp;
        cin >> tmp;
        if (A > tmp && !stop) A += tmp;
        else stop = true;
    }
    cout << A << "\n";
}