#include <bits/stdc++.h>
using namespace std;
constexpr char nl = '\n';
template <class array, class B>
array &&mini(array &&a, B &&b) {
  if (b < a) a = b;
  return a;
}
template <class array, class B>
array &&maxi(array &&a, B &&b) {
  if (b > a) a = b;
  return a;
}
int first_bit(int x) { return x == 0 ? 0 : sizeof(x) * 8 - __builtin_clz(x); }
int ceil2(int x) { return x < 2 ? x : 1 << first_bit(x - 1); }
constexpr int inf = 0x3f3f3f3f;
constexpr long long inf_l = 0x3f3f3f3f3f3f3f3f;
struct Debug;
template <class T>
auto _is_debug_func(T &&x)
    -> decltype(x(declval<add_lvalue_reference<Debug>::type>()), true_type{});
false_type _is_debug_func(...);
template <class T>
struct is_debug_func : decltype(_is_debug_func(declval<T>())) {};
;
template <class T>
auto _is_func(T &&x) -> decltype(x(), true_type{});
false_type _is_func(...);
template <class T>
struct is_func : decltype(_is_func(declval<T>())) {};
template <class T>
auto _is_string(T &&x) -> decltype(string(x), true_type{});
false_type _is_string(...);
template <class T>
struct is_string : decltype(_is_string(declval<T>())) {};
template <class T>
auto _is_ptr(T &&x)
    -> decltype(*x, typename enable_if<is_string<T>() == false, int>::type(),
                true_type{});
false_type _is_ptr(...);
template <class T>
struct is_ptr : decltype(_is_ptr(declval<T>())) {};
;
template <class T>
auto _is_container(T &&x)
    -> decltype(x.begin(),
                typename enable_if<is_string<T>() == false, int>::type(),
                true_type{});
false_type _is_container(...);
template <class T>
struct is_container : decltype(_is_container(declval<T>())) {};
template <class Iter>
struct Off {
  Iter _a, _b;
};
template <class T>
auto O(T &&x)
    -> decltype(typename enable_if<is_container<T>() == true, int>::type(),
                Off<decltype(x.begin())>()) {
  return {x.begin(), x.end()};
}
template <class T>
auto O(T &&x)
    -> decltype(typename enable_if<is_container<T>() == false, int>::type(),
                x) {
  return x;
}
struct Debug {
  Debug() { cerr << boolalpha << fixed << setprecision(0); }
  ~Debug() { cerr << nl; }
  Debug &operator()(int x = 1) {
    for (auto _ = (0), ___ = ((x)-1); _ <= ___; ++_) *this << "  ";
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(cerr << x,
                  typename enable_if<
                      is_func<T>() == false && is_ptr<T>() == false &&
                          is_integral<typename remove_reference<T>::type>() ==
                              true,
                      int>::type(),
                  *this) {
    using L = long long;
    if (abs(int(x)) == inf || abs(L(x)) == inf_l)
      cerr << ((int(x) == inf || L(x) == inf_l)     ? "+∞"
               : (int(x) == -inf || L(x) == -inf_l) ? "-∞"
                                                    : "?");
    else
      cerr << x;
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(cerr << x,
                  typename enable_if<
                      is_func<T>() == false && is_ptr<T>() == false &&
                          is_integral<typename remove_reference<T>::type>() ==
                              false,
                      int>::type(),
                  *this) {
    cerr << x;
    return *this;
  }
  template <class T>
  auto operator<<(T &&x) -> decltype(x.first, *this) {
    return *this << "(" << O(x.first) << ", " << O(x.second) << ")";
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_container<T>() == true, int>::type(),
                  *this) {
    *this << "{\n";
    for (auto a = x.begin(); a != x.end(); ++a)
      *this << "  " << distance(x.begin(), a) << ": " << O(*a) << '\n';
    return *this << "}";
  }
  template <class T>
  auto operator<<(T &&x) -> decltype(x._a, *this) {
    *this << "{";
    for (auto a = x._a, b = x._b; a != b; ++a)
      *this << O(*a) << (next(a) == b ? "" : ", ");
    return *this << "}";
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_func<T>() == true, int>::type(),
                  *this) {
    x();
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_debug_func<T>() == true, int>::type(),
                  *this) {
    x(*this);
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_ptr<T>() == true &&
                                         is_func<T>() == false &&
                                         is_debug_func<T>() == false,
                                     int>::type(),
                  *this) {
    return *this << *x;
  }
};
struct DebugOff {
  template <class T>
  DebugOff &operator<<(T &&) {
    return *this;
  }
  DebugOff &operator()(int = 0) { return *this; }
};
using VI = vector<int>;
using VVI = vector<VI>;
using L = long long;
using VL = vector<L>;
using VB = vector<bool>;
using II = pair<int, int>;
using VII = vector<II>;
using VVII = vector<VII>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  VL in(n);
  for (L &ai : in) cin >> ai;
  vector<vector<L>> dp(n + 1, vector<L>(3));
  for (auto i = (1), i__ = (n); i <= i__; ++i) {
    dp[i][0] = max(0LL, dp[i - 1][0] + in[i - 1]);
    dp[i][1] = max(0LL, dp[i - 1][1] + in[i - 1] * x);
    dp[i][1] = max(dp[i][1], dp[i - 1][0] + in[i - 1] * x);
    dp[i][2] = max(0LL, dp[i - 1][2] + in[i - 1]);
    dp[i][2] = max(dp[i][2], dp[i - 1][1] + in[i - 1]);
    dp[i][2] = max(dp[i][2], dp[i - 1][0] + in[i - 1]);
  }
  L answer = 0;
  for (auto &v : dp)
    for (L a : v) answer = max(answer, a);
  cout << answer << '\n';
}

### Prompt

Please provide a CPP coded solution to the problem described below:

You are given an array a consisting of n integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.

You may choose at most one consecutive subarray of a and multiply all values contained in this subarray by x. You want to maximize the beauty of array after applying at most one such operation.

Input

The first line contains two integers n and x (1 ≤ n ≤ 3 ⋅ 10^5, -100 ≤ x ≤ 100) — the length of array a and the integer x respectively.

The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the array a.

Output

Print one integer — the maximum possible beauty of array a after multiplying all values belonging to some consecutive subarray x.

Examples

Input


5 -2
-3 8 -2 1 -6


Output


22


Input


12 -3
1 3 3 7 1 3 3 7 1 3 3 7


Output


42


Input


5 10
-1 -2 -3 -4 -5


Output


0

Note

In the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).

In the second test case we don't need to multiply any subarray at all.

In the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
constexpr char nl = '\n';
template <class array, class B>
array &&mini(array &&a, B &&b) {
  if (b < a) a = b;
  return a;
}
template <class array, class B>
array &&maxi(array &&a, B &&b) {
  if (b > a) a = b;
  return a;
}
int first_bit(int x) { return x == 0 ? 0 : sizeof(x) * 8 - __builtin_clz(x); }
int ceil2(int x) { return x < 2 ? x : 1 << first_bit(x - 1); }
constexpr int inf = 0x3f3f3f3f;
constexpr long long inf_l = 0x3f3f3f3f3f3f3f3f;
struct Debug;
template <class T>
auto _is_debug_func(T &&x)
    -> decltype(x(declval<add_lvalue_reference<Debug>::type>()), true_type{});
false_type _is_debug_func(...);
template <class T>
struct is_debug_func : decltype(_is_debug_func(declval<T>())) {};
;
template <class T>
auto _is_func(T &&x) -> decltype(x(), true_type{});
false_type _is_func(...);
template <class T>
struct is_func : decltype(_is_func(declval<T>())) {};
template <class T>
auto _is_string(T &&x) -> decltype(string(x), true_type{});
false_type _is_string(...);
template <class T>
struct is_string : decltype(_is_string(declval<T>())) {};
template <class T>
auto _is_ptr(T &&x)
    -> decltype(*x, typename enable_if<is_string<T>() == false, int>::type(),
                true_type{});
false_type _is_ptr(...);
template <class T>
struct is_ptr : decltype(_is_ptr(declval<T>())) {};
;
template <class T>
auto _is_container(T &&x)
    -> decltype(x.begin(),
                typename enable_if<is_string<T>() == false, int>::type(),
                true_type{});
false_type _is_container(...);
template <class T>
struct is_container : decltype(_is_container(declval<T>())) {};
template <class Iter>
struct Off {
  Iter _a, _b;
};
template <class T>
auto O(T &&x)
    -> decltype(typename enable_if<is_container<T>() == true, int>::type(),
                Off<decltype(x.begin())>()) {
  return {x.begin(), x.end()};
}
template <class T>
auto O(T &&x)
    -> decltype(typename enable_if<is_container<T>() == false, int>::type(),
                x) {
  return x;
}
struct Debug {
  Debug() { cerr << boolalpha << fixed << setprecision(0); }
  ~Debug() { cerr << nl; }
  Debug &operator()(int x = 1) {
    for (auto _ = (0), ___ = ((x)-1); _ <= ___; ++_) *this << "  ";
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(cerr << x,
                  typename enable_if<
                      is_func<T>() == false && is_ptr<T>() == false &&
                          is_integral<typename remove_reference<T>::type>() ==
                              true,
                      int>::type(),
                  *this) {
    using L = long long;
    if (abs(int(x)) == inf || abs(L(x)) == inf_l)
      cerr << ((int(x) == inf || L(x) == inf_l)     ? "+∞"
               : (int(x) == -inf || L(x) == -inf_l) ? "-∞"
                                                    : "?");
    else
      cerr << x;
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(cerr << x,
                  typename enable_if<
                      is_func<T>() == false && is_ptr<T>() == false &&
                          is_integral<typename remove_reference<T>::type>() ==
                              false,
                      int>::type(),
                  *this) {
    cerr << x;
    return *this;
  }
  template <class T>
  auto operator<<(T &&x) -> decltype(x.first, *this) {
    return *this << "(" << O(x.first) << ", " << O(x.second) << ")";
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_container<T>() == true, int>::type(),
                  *this) {
    *this << "{\n";
    for (auto a = x.begin(); a != x.end(); ++a)
      *this << "  " << distance(x.begin(), a) << ": " << O(*a) << '\n';
    return *this << "}";
  }
  template <class T>
  auto operator<<(T &&x) -> decltype(x._a, *this) {
    *this << "{";
    for (auto a = x._a, b = x._b; a != b; ++a)
      *this << O(*a) << (next(a) == b ? "" : ", ");
    return *this << "}";
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_func<T>() == true, int>::type(),
                  *this) {
    x();
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_debug_func<T>() == true, int>::type(),
                  *this) {
    x(*this);
    return *this;
  }
  template <class T>
  auto operator<<(T &&x)
      -> decltype(typename enable_if<is_ptr<T>() == true &&
                                         is_func<T>() == false &&
                                         is_debug_func<T>() == false,
                                     int>::type(),
                  *this) {
    return *this << *x;
  }
};
struct DebugOff {
  template <class T>
  DebugOff &operator<<(T &&) {
    return *this;
  }
  DebugOff &operator()(int = 0) { return *this; }
};
using VI = vector<int>;
using VVI = vector<VI>;
using L = long long;
using VL = vector<L>;
using VB = vector<bool>;
using II = pair<int, int>;
using VII = vector<II>;
using VVII = vector<VII>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  VL in(n);
  for (L &ai : in) cin >> ai;
  vector<vector<L>> dp(n + 1, vector<L>(3));
  for (auto i = (1), i__ = (n); i <= i__; ++i) {
    dp[i][0] = max(0LL, dp[i - 1][0] + in[i - 1]);
    dp[i][1] = max(0LL, dp[i - 1][1] + in[i - 1] * x);
    dp[i][1] = max(dp[i][1], dp[i - 1][0] + in[i - 1] * x);
    dp[i][2] = max(0LL, dp[i - 1][2] + in[i - 1]);
    dp[i][2] = max(dp[i][2], dp[i - 1][1] + in[i - 1]);
    dp[i][2] = max(dp[i][2], dp[i - 1][0] + in[i - 1]);
  }
  L answer = 0;
  for (auto &v : dp)
    for (L a : v) answer = max(answer, a);
  cout << answer << '\n';
}

```