The function f(a_1,a_2,…,a_n) represents the largest sum of elements on a non-empty subsegment in the array a_1,a_2,…,a_n.
You are given an array a_1,a_2,…,a_n.
You can spend one coin and decrease any element of a by 1.
Another function, g(k), represents the smallest value of f(a_1,a_2,…,a_n) you can achieve by spending at most k coins.
Find g(1)+g(2)+…+g(k). As this value may be very large, find it modulo 998,244,353.