#include #include using namespace std; #define LL long long const LL inf=((LL)1e14); LL a[1005],f[1005]; int main() { long T,i,j,n;LL p,ans,ans0; scanf("%ld",&T); while (T--) { scanf("%ld%I64d",&n,&p);ans0=-inf; for (i=1;i<=n;i++) scanf("%I64d",&a[i]); for (i=1;i<=n;i++) { swap(a[i],p);ans=-inf; for (j=1;j<=n;j++) {f[j]=max(f[j-1],(LL)0)+a[j];ans=max(ans,f[j]);} ans0=max(ans0,ans);swap(a[i],p); } printf("%I64d\n",ans0); } return 0; }