import sys, math input = lambda: sys.stdin.readline()[:-1] def MI(): return map(int, input().split()) inf = 10**18 class BIT: def __init__(self, n): self.size = n self.n0 = 1 << (n.bit_length() - 1) self.tree = [0] * (n + 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i def range_sum(self, l, r): return self.sum(r - 1) - self.sum(l - 1) def get(self, i): return self.sum(i) - self.sum(i - 1) def lower_bound(self, x): pos = 0 plus = self.n0 while plus > 0: if pos + plus <= self.size and self.tree[pos + plus] < x: x -= self.tree[pos + plus] pos += plus plus //= 2 return pos # https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree # 区間加算 / 区間和 class RangeUpdate: def __init__(self, n): self.p = BIT(n) self.q = BIT(n) def add(self, l, r, x): self.p.add(l, -x * (l-1)) self.p.add(r-1, x * (r-1)) self.q.add(l, x) self.q.add(r-1, -x) def get_sum(self, l, r): sum_p = self.p.sum(r-1) + self.q.sum(r-1) * (r-1) sum_q = self.p.sum(l-1) + self.q.sum(l-1) * (l-1) return sum_p - sum_q n,k = MI() a = list(MI()) def isok(mid): bit = RangeUpdate(n) for i in range(n): bit.add(i, i+1, a[i]) cnt = 0 for left in range(n): mn = bit.get_sum(left, left+1) if mn1: mid = (l+r)//2 if isok(mid): l = mid else: r = mid print(l)