import bisect import sys def problem_input(): inputs = sys.stdin.read() inputs = list(map(int, inputs.split())) n = inputs[0] d = inputs[1] k = inputs[2] xlist = inputs[3:] return n, d, k, xlist def test_input1(): n = 7 d = 2 k = 1000 xlist = [1,3,5,1,4,4,7] return n, d, k, xlist def test_input2(): n = 5 d = 4 k = 100 xlist = [1,2,1,2,1] return n, d, k, xlist def test_input3(): n = 5 d = 1 k = 100 xlist = [5,4,3,3,1] return n, d, k, xlist def bisect_method(n, d, k, xlist): sorted_list = [(xlist[0], 0)] diff_max = 0 result = (0, 0) for i in range(1, n): while (i - sorted_list[0][1]) > d: sorted_list = sorted_list[1:] stock_diff = xlist[i] - sorted_list[0][0] if diff_max < stock_diff: diff_max = stock_diff result = (sorted_list[0][1], i) bisect.insort(sorted_list, (xlist[i], i)) return diff_max, result def sort_method(n, d, k, xlist): minimum = (xlist[0], 0) diff_max = 0 result = (0, 0) for i in range(1, n): # refresh if i - minimum[1] > d: tmp = min(xlist[i-d:i]) minimum = (tmp, xlist.index(tmp)) # max stock_diff = xlist[i] - minimum[0] if diff_max < stock_diff: result = (minimum[1], i) diff_max = stock_diff # min if xlist[i] <= minimum[0]: minimum = (xlist[i], i) return diff_max, result # main n,d,k,xlist = problem_input() # n,d,k,xlist = test_input1() # diff_max, result = bisect_method(n, d, k, xlist) diff_max, result = sort_method(n, d, k, xlist) print(diff_max * k) if diff_max != 0: print("{0} {1}".format(result[0], result[1]))