Easiest Sum

배열과 k개의 코인이 주어지고 코인 하나로 원소 하나를 1 줄일 수 있을 때, g(t)를 코인 t개 이하로 만들 수 있는 최대 부분배열 합의 최솟값이라 하면 g(1)부터 g(k)까지의 합을 998244353으로 나눈 나머지를 구한다.

어려움9이분 탐색그리디정렬누적 합아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

The function f(a_1,a_2,,a_n)f(a\_1, a\_2, \ldots, a\_n) represents the largest sum of elements on a non-empty subsegment in the array a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n.

You are given an array a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n

You can spend one coin and decrease any element of aa by 11.

Another function, g(k)g(k), represents the smallest value of f(a_1,a_2,,a_n)f(a\_1, a\_2, \ldots, a\_n) you can achieve by spending at most kk coins.

Find g(1)+g(2)++g(k)g(1) + g(2) + \ldots + g(k). As this value may be very large, find it modulo 998,244,353998\\,244\\,353.

입력

The first line of input contains one integer, nn (1n100,0001 \leq n \leq 100\\,000): the number of elements in aa.

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (108a_i108-10^8 \leq a\_i \leq 10^8).

The third line contains one integer kk (1k10131 \leq k \leq 10^{13}).

출력

Print g(1)+g(2)++g(k)g(1) + g(2) + \ldots + g(k), modulo 998,244,353998\\,244\\,353.

힌트

In the first example, g(1)=2,g(2)=2,g(3)=1g(1)=2, g(2)=2,g(3)=1.

In the second example, g(1)=4g(1)=-4.