#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 50;
ll a[N], m1[N], m2[N];
int main()
{
    int n, x;
    scanf("%d%d", &n, &x);
    for (int i = 1; i <= n; i++)
        scanf("%lld", a + i);
    ll sum1 = 0, tmp1 = 0;
    ll sum2 = 0, tmp2 = 0;
    int l1 = 0, r1 = 0, l2 = 0, r2 = 0;
    for (int i = 1; i <= n; i++)
        m1[i] = max(m1[i - 1] + a[i], 0ll),
        m2[i] = min(m2[i - 1] + a[i], 0ll);
    if (x < 0)
    {

    }
    sum1 = 0, tmp1 = 0;
    for (int i = 0; i < n; i++)
    {
        tmp1 += a[i];
        if (tmp1 < 0) tmp1 = 0, l1 = i + 1;
        if (tmp1 > sum1) sum1 = tmp1, r1 = i;
    }
    printf("%lld", sum1);
    return 0;
}
