#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef float fl;
typedef double dou;
typedef long double ld;
#define register int ri;
const ll inf = 1e9;
const ll inf_common = 0x3f3f3f3f;
const ll inf_larger = 0x7fffffff;
const ll inf_ll = 1e18;
const ll mod = 998244353;
const dou eps = 1e-6;
inline ll read()
{
ll ans = 0;
ll f = 1;
char c = getchar();
while( c < '0' || c > '9' )
{
if( c == '-' )
{
f = -1;
}
c = getchar();
}
while( c >= '0' && c <= '9' )
{
ans = ( ans << 3 ) + ( ans << 1 ) + ( c - 48 );
c = getchar();
}
return ans * f;
}
inline void write( ll x )
{
if( x < 0 )
{
putchar( '-' );
x = -x;
}
if( x > 9 )
{
write( x / 10 );
}
putchar( x % 10 + '0' );
}
ll a[1000001] = {0};
ll b[1000001] = {0};
int main()
{
ll n = read();
ll k = read();
ll i = 0;
ll pos = 0;
ll sum = 0;
ll ans = 0;
bool flag = 0;
for( i = 1 ; i <= n ; i++ )
{
a[i] = read();
if( a[i] >= 0 && !flag )
{
flag = 1;
pos = i - 1;
}
a[i] %= mod;
b[i] = b[i - 1] + a[i];
b[i] %= mod;
sum += ( a[i] + 1 ) * ( a[i] + 1 );
sum %= mod;
}
ans = sum;
for( i = 2 ; i <= k ; i++ )
{
sum %= mod;
sum += ( ( ( b[n] - b[pos] ) % mod * 2 ) % mod + ( ( n - pos ) % mod ) * ( ( 2 * i - 1 ) % mod ) ) % mod;
sum %= mod;
while( pos )
{
if( a[pos] + i <= 0 )
{
break;
}
sum += ( a[pos] * a[pos] ) + 1 % mod;
sum %= mod;
pos--;
}
ans += sum % mod;
ans %= mod;
}
write( ans );
return 0;
}