On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then the cost of item x_{j} is a_{x}_{j} + x_{j}·k for 1 ≤ j ≤ k. In other words, the cost of an item is equal to its base cost in addition to its index multiplied by the factor k.

Sagheer wants to buy as many souvenirs as possible without paying more than S Egyptian pounds. Note that he cannot buy a souvenir more than once. If there are many ways to maximize the number of souvenirs, he will choose the way that will minimize the total cost. Can you help him with this task?


-----Input-----

The first line contains two integers n and S (1 ≤ n ≤ 10^5 and 1 ≤ S ≤ 10^9) — the number of souvenirs in the market and Sagheer's budget.

The second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5) — the base costs of the souvenirs.


-----Output-----

On a single line, print two integers k, T — the maximum number of souvenirs Sagheer can buy and the minimum total cost to buy these k souvenirs.


-----Examples-----
Input
3 11
2 3 5

Output
2 11

Input
4 100
1 2 5 6

Output
4 54

Input
1 7
7

Output
0 0



-----Note-----

In the first example, he cannot take the three items because they will cost him [5, 9, 14] with total cost 28. If he decides to take only two items, then the costs will be [4, 7, 11]. So he can afford the first and second items.

In the second example, he can buy all items as they will cost him [5, 10, 17, 22].

In the third example, there is only one souvenir in the market which will cost him 8 pounds, so he cannot buy it.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting


Solutions:
def Solution(arr, N, S):
	l = 0
	r = N
	ans = [0, 0]
	while l <= r:
		mid = (l + r) // 2
		res = isValid(arr, S, mid)
		if res[0]:
			l = mid + 1
			ans = (mid, res[1])
		else:
			r = mid - 1
	return ans

def isValid(arr, S, k):
	tempArr = []
	for j in range(len(arr)):
		tempArr.append(arr[j] + (j + 1) * k)
	tempArr = sorted(tempArr)
	tempSum = 0
	for i in range(k):
		tempSum += tempArr[i]
		if tempSum > S:
			return [False, 0]
	return [True, tempSum]
(N, S) = map(int, input().split())
arr = list(map(int, input().split()))
res = Solution(arr, N, S)
print(res[0], res[1])


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
from heapq import heapify, heappop

def min_cost(a, k):
	if k > len(a):
		return False
	new_a = [a[i] + (i + 1) * k for i in range(len(a))]
	heapify(new_a)
	s = 0
	for _ in range(k):
		s += heappop(new_a)
	return s
n = nextInt()
S = nextInt()
a = [nextInt() for _ in range(n)]
low = 0
high = n + 1
while low + 1 < high:
	mid = (low + high) // 2
	if min_cost(a, mid) <= S:
		low = mid
	else:
		high = mid
print(low, min_cost(a, low))


def can(a, s, k):
	global cost
	costs = [a[i] + (i + 1) * k for i in range(n)]
	costs.sort()
	cost = sum(costs[:k])
	return cost <= s
cost = 0
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(lt, rt) = (0, n + 1)
while lt + 1 < rt:
	mid = (lt + rt) // 2
	if can(a, s, mid):
		lt = mid
	else:
		rt = mid
can(a, s, lt)
print(lt, cost)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = 'abcdefghijklmnopqrstuvwxyz'

def check(n, arr, S):
	lar = sorted([n * (i + 1) + j for (i, j) in enumerate(arr)])
	lar.sort()
	sm = sum(lar[:n])
	if sm <= S:
		return sm
	return -1
for _ in range(1):
	(n, S) = f()
	l = il()
	(lf, rt) = (0, n)
	ans = 0
	mxn = 0
	while lf <= rt:
		md = (lf + rt) // 2
		x = check(md, l, S)
		if x >= 0:
			if md > mxn:
				ans = x
				mxn = md
			lf = md + 1
		else:
			rt = md - 1
	print(mxn, ans)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (0, n)
new_s = 0
ans = 0
while l < r:
	mid = (l + r + 1) // 2
	new_a = sorted([a[i] + (i + 1) * mid for i in range(n)])
	new_s = sum(new_a[:mid])
	if new_s > s:
		r = mid - 1
	else:
		ans = new_s
		l = mid
print(l, ans)


(n, s) = map(int, input().split())
price = list(map(int, input().split()))

def find(k):
	new = sorted([price[i] + (i + 1) * k for i in range(n)])
	tot = sum(new[:k])
	if tot <= s:
		return tot
	return 0
(l, h) = (0, n)
while l < h:
	mid = int((l + h + 1) / 2)
	if find(mid):
		l = mid
	else:
		h = mid - 1
print(l, find(l))


def fes(arr, mid):
	res = 0
	n = len(arr)
	l = []
	for i in range(n):
		l.append(arr[i] + (i + 1) * mid)
	l.sort()
	for i in range(mid):
		res += l[i]
	return res
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = 0
r = n
ans = [0, 0]
while l <= r:
	mid = (r + l) // 2
	res = fes(arr, mid)
	if res <= k:
		ans = [mid, res]
		l = mid + 1
	else:
		r = mid - 1
print(ans[0], ans[1])


def check(li, mid, c):
	s = []
	for i in range(len(li)):
		s.append(li[i] + mid * (i + 1))
	s.sort()
	x = 0
	for i in range(mid):
		x += s[i]
	if x > c:
		return (False, x)
	return (True, x)

def main(li, c):
	start = 0
	end = len(li)
	ans = -1
	sol = -1
	while start <= end:
		mid = (start + end) // 2
		(z, y) = check(li, mid, c)
		if z == True:
			ans = mid
			sol = y
			start = mid + 1
		else:
			end = mid - 1
	print(ans, sol)
(n, c) = [int(x) for x in input().split()]
li = [int(x) for x in input().split()]
main(li, c)


from heapq import heappop, heapify

def main():

	def helper(e):
		if e:
			l = [a + b for (a, b) in zip(aa, range(e, (e + 1) * n, e))]
			heapify(l)
			return sum((heappop(l) for _ in range(e)))
		return 0
	(n, s) = map(int, input().split())
	aa = list(map(int, input().split()))
	(lo, hi) = (0, n)
	while lo < hi:
		mid = (lo + hi + 1) // 2
		t = helper(mid)
		if s < t:
			hi = mid - 1
		else:
			lo = mid
	print(lo, helper(lo))
main()


def BinarySearch(n, s, a):
	(N, S) = (int(n), int(s))
	(ans, total, _min, _max) = (0, 0, 0, N)
	while _min <= _max:
		K = (_min + _max) // 2
		b = sorted([int(a[i]) + (i + 1) * K for i in range(N)])
		cost = sum([b[i] for i in range(K)])
		if cost <= S:
			ans = K
			total = cost
			_min = K + 1
		else:
			_max = K - 1
	print(str(ans) + ' ' + str(total))
(N, S) = str(input()).split(' ')
A = input().split(' ')
BinarySearch(N, S, A)


def check(num):
	cost = []
	for i in range(n):
		cost.append(a[i] + (i + 1) * num)
	cost.sort()
	if sum(cost[0:num]) <= s:
		return (True, sum(cost[0:num]))
	return (False, -1)
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
low = 0
high = n
while low < high:
	mid = (low + high) // 2
	if check(mid)[0]:
		low = mid + 1
	else:
		high = mid - 1
if check(low)[0]:
	print(low, check(low)[1])
else:
	print(low - 1, check(low - 1)[1])


(n, s) = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

def tr(m):
	bb = [x + (i + 1) * m for (i, x) in enumerate(b)]
	bb = sorted(bb)
	res = sum(bb[:m])
	if res <= s:
		return res
	else:
		return None
res = None
lo = 0
hi = n
d = {}
maxgood = -1
while lo < hi:
	mid = (lo + hi) // 2
	temp = tr(mid)
	d[mid] = temp
	if temp is not None:
		lo = mid + 1
		maxgood = max(maxgood, mid)
	else:
		hi = mid
temp = tr(hi)
d[hi] = temp
if temp is not None:
	maxgood = max(maxgood, hi)
temp = tr(lo)
d[lo] = temp
if temp is not None:
	maxgood = max(maxgood, lo)
temp = tr(mid)
d[mid] = temp
if temp is not None:
	maxgood = max(maxgood, mid)
print(maxgood, d[maxgood])


info = input().split()
a = [int(item) for item in input().split()]
n = int(info[0])
S = int(info[1])
left = 0
right = len(a) - 1
numItem = 0
minCost = 0
while left <= right:
	mid = (left + right) // 2
	c = [x + (ind + 1) * (mid + 1) for (ind, x) in enumerate(a)]
	c.sort()
	total = 0
	for i in range(mid + 1):
		total += c[i]
	if total <= S:
		numItem = mid + 1
		minCost = total
		left = mid + 1
	else:
		right = mid - 1
print(numItem, minCost)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque

def total_sum(k):
	new = [l[i] + (i + 1) * k for i in range(n)]
	return sum(sorted(new)[:k])
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
a = 0
b = n
while a < b:
	mid = (a + b + 1) // 2
	if total_sum(mid) <= s:
		a = mid
	else:
		b = mid - 1
print(a, total_sum(a))


from sys import stdin

def cost_of(data, k):
	kl = []
	for (index, item) in enumerate(data):
		kl.append(item + (index + 1) * k)
	kl.sort()
	accu = 0
	for i in range(0, k):
		accu += kl[i]
	return accu
(n, s) = map(int, stdin.readline().rstrip().split())
data = list(map(int, stdin.readline().rstrip().split()))
(left, right) = (0, n)
(cleft, cright) = (0, cost_of(data, n))
if s >= cright:
	print('{0} {1}'.format(n, cright))
	exit()
last_center = -1
center = -1
while left <= right:
	last_center = center
	center = (left + right) // 2
	ccenter = cost_of(data, center)
	if center == last_center:
		rs = right if s >= cright else left
		left = rs
		break
	if s < ccenter:
		right = center - 1
		cright = cost_of(data, right)
	else:
		left = center
		cleft = cost_of(data, left)
print(left, cost_of(data, left))


def buy(k):
	prices = sorted([a[i] + (i + 1) * k for i in range(n)])
	return sum(prices[:k])
(n, have) = map(int, input().split())
a = list(map(int, input().split()))
spend = 0
(left, right) = (-1, n + 1)
while left + 1 < right:
	mid = left + right >> 1
	need = buy(mid)
	if need <= have:
		left = mid
		spend = need
	else:
		right = mid
print(left, spend)


(n, s) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = n + 1
while r - l > 1:
	m = l + (r - l) // 2
	B = A.copy()
	for j in range(n):
		B[j] = A[j] + (j + 1) * m
	B.sort()
	if sum(B[:m]) > s:
		r = m
	else:
		l = m
B = A.copy()
for j in range(n):
	B[j] = A[j] + (j + 1) * l
B.sort()
print(l, sum(B[:l]))


(n, s) = list(map(int, input().split()))
arr = list(map(int, input().split()))

def buy(k):
	nonlocal n, s, arr
	if k == 0:
		return 0
	temp = sorted([arr[i - 1] + i * k for i in range(1, n + 1)])
	return sum(temp[:k])

def main():
	(f, l) = (0, n)
	while f < l:
		if f == l - 1:
			(a, b) = (buy(f), buy(l))
			return (l, b) if b <= s else (f, a)
		m = (f + l) // 2
		if buy(m) <= s:
			f = m
		else:
			l = m
(a, b) = main()
print(a, b)


import copy

def solve(n, s, l):
	a = 1
	b = n
	solu = []
	ans = []
	while a <= b:
		k = (a + b) // 2
		x = calc(k, l)
		if x == s:
			return [k, s]
		elif x > s:
			b = k - 1
		else:
			a = k + 1
			solu.append(k)
			ans.append(x)
	if len(solu) != 0:
		i = solu.index(max(solu))
		return [solu[i], ans[i]]
	else:
		return [0, 0]

def calc(k, l):
	vari = copy.deepcopy(l)
	for i in range(len(vari)):
		vari[i] += (i + 1) * k
	vari = sorted(vari)
	suma = 0
	for i in range(k):
		suma += vari[i]
	return suma
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
x = solve(n, s, l)
print(*x)


def func(m):
	global a
	a1 = [a[i] + (1 + i) * m for i in range(len(a))]
	a1.sort()
	s = 0
	for i in range(m):
		s += a1[i]
	return s
l = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
low = 0
high = l[0]
mid = (low + high) // 2
while low <= high:
	mid = (low + high) // 2
	x = func(mid)
	if x > l[1]:
		high = mid - 1
	elif x < l[1]:
		low = mid + 1
	else:
		low = mid
		break
if func(mid) > l[1]:
	mid -= 1
print(mid, func(mid))


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def works(A, K, S):
	B = []
	for (i, a) in enumerate(A):
		B.append(a + (i + 1) * K)
	B.sort()
	cost = sum(B[:K])
	return (cost <= S, cost)

def solve():
	(N, S) = getInts()
	A = getInts()
	left = 0
	right = N
	assert works(A, left, S)
	left_cost = 0
	(x, y) = works(A, right, S)
	if x:
		print(right, y)
		return
	while right - left > 1:
		middle = (left + right) // 2
		(x, y) = works(A, middle, S)
		if x:
			left = middle
			left_cost = y
		else:
			right = middle
	print(left, left_cost)
	return
solve()


import sys, os, math
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def is_fesiable(arr, mid, s):
	n = len(arr)
	b = [0] * n
	for i in range(n):
		b[i] = arr[i] + (i + 1) * mid
	b.sort()
	ans = sum(b[:mid])
	return ans

def main():
	(n, s) = map(int, sys.stdin.readline().strip().split())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	l = 0
	r = n
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		if is_fesiable(arr, mid, s) <= s:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	print(ans, is_fesiable(arr, ans, s))
main()


(n, S) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
r = n + 1
while r > l + 1:
	k = -(-(l + r) // 2)
	cost = 0
	a_new = [a[i] + (i + 1) * k for i in range(n)]
	a_new.sort()
	for i in range(k):
		cost += a_new[i]
	if cost <= S:
		l = k
	else:
		r = k
a_new = [a[i] + (i + 1) * l for i in range(n)]
a_new.sort()
cost = 0
for i in range(l):
	cost += a_new[i]
print(l, cost)


for _ in range(1):
	(n, budget) = map(int, input().split())
	costs = list(map(int, input().split()))
	start = 0
	end = n + 1
	while start < end - 1:
		mid = start + (end - start) // 2
		binary = [0 for _ in range(n)]
		for i in range(n):
			binary[i] = costs[i] + (i + 1) * mid
		binary.sort()
		total = 0
		for i in range(mid):
			total += binary[i]
		if total <= budget:
			start = mid
		else:
			end = mid
	binary = [0 for _ in range(n)]
	for i in range(n):
		binary[i] = costs[i] + (i + 1) * start
	binary.sort()
	total = 0
	for i in range(start):
		total += binary[i]
	print(start, total)


def attempt_buy_n_items(n, budget, prices):
	prices = list(prices)
	for (i, price) in enumerate(prices):
		prices[i] = price + n * (i + 1)
	prices = sorted(prices)
	if sum(prices[:n]) <= budget:
		return sum(prices[:n])
(n, b) = [int(n) for n in input().split()]
prices = [int(n) for n in input().split()]
items_to_buy = n
max_items = 0
min_price = 0
(l, r) = (1, n)
while l <= r:
	mid = (l + r) // 2
	bought = attempt_buy_n_items(mid, b, prices)
	if bought is not None:
		max_items = mid
		min_price = bought
		l = mid + 1
	else:
		r = mid - 1
print(max_items, min_price)


import sys
input = sys.stdin.readline

def judge(x):
	b = [a[i] + (i + 1) * x for i in range(n)]
	b.sort()
	s = sum(b[:x])
	return s <= S

def binary_search():
	(l, r) = (0, n)
	while l <= r:
		mid = (l + r) // 2
		if judge(mid):
			l = mid + 1
		else:
			r = mid - 1
	return r
(n, S) = map(int, input().split())
a = list(map(int, input().split()))
k = binary_search()
b = [a[i] + (i + 1) * k for i in range(n)]
b.sort()
T = sum(b[:k])
print(k, T)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
beg = 0
end = n

def trier(k):
	p = sorted([a[i] + k * (i + 1) for i in range(n)])
	som = sum(p[0:k])
	return 0 if som > s else som
l = 0
r = n
while l < r:
	k = (l + r + 1) // 2
	if trier(k):
		l = k
	else:
		r = k - 1
print(l, trier(l))


def binarySearch(k, x, ls):
	l = 0
	r = k
	while l <= r:
		mid = (l + r) // 2
		b = price(mid, ls)
		if b == x:
			return mid
		elif b < x:
			l = mid + 1
		else:
			r = mid - 1
	return l - 1

def price(k, ls):
	ar = []
	for i in range(len(ls)):
		p = ls[i] + (i + 1) * k
		ar.append(p)
	ar.sort()
	return sum(ar[:k])
(k, n) = map(int, input().split())
ls = list(map(int, input().split()))
mx = 0
cnt = 0
s = 0
t = binarySearch(k, n, ls)
print(f'{t} {price(t, ls)}')


def ispossible(a, k):
	l = [0] * len(a)
	for i in range(len(a)):
		l[i] = a[i] + (i + 1) * k
	l.sort()
	return sum(l[:k])
(n, S) = map(int, input().split())
a = list(map(int, input().split()))
nn = [int(i) for i in range(1, n + 1)]
(l, h) = (0, n + 1)
while h - l > 1:
	m = (l + h) // 2
	if ispossible(a, m) <= S:
		l = m
	else:
		h = m
print(l, ispossible(a, l))


import sys

def main():
	(n, s) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	l = 0
	r = n
	bestk = 0
	bests = 0
	while l < r:
		mid = (l + r) // 2
		x = [a[i] + (i + 1) * mid for i in range(n)]
		x.sort()
		t = 0
		for i in range(mid):
			t += x[i]
		if t <= s:
			bests = t
			bestk = mid
			l = mid + 1
		else:
			r = mid - 1
	mid = l
	x = [a[i] + (i + 1) * mid for i in range(n)]
	x.sort()
	t = 0
	for i in range(mid):
		t += x[i]
	if t <= s:
		bestk = mid
		bests = t
	print(bestk, bests)
main()


def canBuy(k):
	fullCost = [(i + 1) * k + cost[i] for i in range(0, n)]
	fullCost = sorted(fullCost)
	fullSum = sum(fullCost[:k])
	return fullSum <= money

def canBuyCost(k):
	fullCost = [(i + 1) * k + cost[i] for i in range(0, n)]
	fullCost = sorted(fullCost)
	fullSum = sum(fullCost[:k])
	return fullSum if fullSum <= money else -1
(n, money) = [int(x) for x in input().split()]
cost = [int(x) for x in input().split()]
left = 0
right = n
while left < right - 1:
	mid = (left + right) // 2
	if canBuy(mid):
		left = mid
	else:
		right = mid
rightRes = canBuyCost(right)
if rightRes == -1:
	print(left, canBuyCost(left))
else:
	print(right, rightRes)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))

def answer(x):
	arr_new = [0]
	for i in range(1, n + 1):
		arr_new.append(arr[i - 1] + i * x)
	arr_new.sort()
	ans = 0
	for j in range(0, x + 1):
		ans = ans + arr_new[j]
	return ans
fin_ans = answer(n)
l = 1
r = n
items = n
if fin_ans > k:
	while r <= n and l <= r and (l >= 1):
		mid = l + (r - l) // 2
		temp_ans = answer(mid)
		if temp_ans <= k:
			fin_ans = temp_ans
			items = mid
		if temp_ans == k:
			break
		elif temp_ans > k:
			r = mid - 1
		else:
			l = mid + 1
if fin_ans > k:
	print('0 0')
else:
	print(str(items) + ' ' + str(fin_ans))


def func(c, k, s, n):
	nc = []
	for i in range(n):
		nc.append(c[i] + (i + 1) * (k + 1))
	nc.sort()
	val = sum(nc[:k + 1])
	if val <= s:
		return val
	else:
		return -1
inp = input().split()
n = int(inp[0])
s = int(inp[1])
c = []
val = input().split()
i = 1
for v in val:
	c.append(int(v))
	i += 1
begin = 0
end = n - 1
flag = 0
while begin <= end:
	mid = (begin + end) // 2
	if func(c, mid, s, n) != -1:
		if mid == n - 1:
			print(mid + 1, func(c, mid, s, n))
			flag = 1
			break
		if func(c, mid + 1, s, n) == -1:
			print(mid + 1, func(c, mid, s, n))
			flag = 1
			break
		else:
			begin = mid + 1
	else:
		end = mid - 1
if flag == 0:
	print('0 0')


def f(arr, k):
	suma = 0
	arr1 = []
	for i in range(0, len(arr)):
		arr1.append(arr[i] + k * (i + 1))
	arr1.sort()
	if k == 1:
		return arr1[0] + 1
	for i in range(0, k):
		try:
			suma = suma + arr1[i]
		except:
			adfasdf = 0
	return suma
(n, S) = map(int, input().split())
A = [int(i) for i in input().split()]
low = 0
high = n
while low < high:
	mid = (low + high) // 2
	cost = f(A, mid)
	if cost < S:
		low = mid + 1
	elif cost >= S:
		high = mid
ans = 0
if f(A, high + 1) <= S:
	ans = high + 1
elif f(A, high) <= S:
	ans = high
elif f(A, low + 1) <= S:
	ans = low + 1
elif f(A, low) <= S:
	ans = low
else:
	ans = low - 1
if ans > n:
	ans = n
suma = 0
arr1 = []
for i in range(0, len(A)):
	arr1.append(A[i] + ans * (i + 1))
arr1.sort()
for i in range(0, ans):
	suma = suma + arr1[i]
print(ans, suma)


import math

def input_int():
	return list(map(int, input().split()))

def calc(a, k):
	b = []
	sm = 0
	for (i, v) in enumerate(a):
		b.append(int(v + (i + 1) * k))
	b = sorted(b)
	for i in range(0, k):
		sm += b[i]
	return sm

def solve():
	[n, s] = input_int()
	a = input_int()
	l = 0
	r = n + 1
	while l < r - 1:
		m = math.floor((l + r) / 2)
		if calc(a, m) > s:
			r = m
		else:
			l = m
	print(l, calc(a, l))
	return
solve()


def read():
	return [int(c) for c in input().split()]

def solve(k, a):
	price = [e + i * k for (i, e) in enumerate(a, 1)]
	price.sort()
	cost = sum((e for (i, e) in enumerate(price) if i < k))
	return cost

def main():
	(n, S) = read()
	a = read()
	(lo, hi) = (0, n + 1)
	while lo < hi - 1:
		mid = (lo + hi) // 2
		if solve(mid, a) <= S:
			lo = mid
		else:
			hi = mid
	print(lo, solve(lo, a))
main()


def check(x, a, u):
	s = 0
	a.sort(key=lambda o: o[0] + o[1] * x)
	for i in range(0, x):
		s += a[i][0] + a[i][1] * x
	if s > u:
		return [False]
	return [True, s]

def binary_search(a, n):
	l = 0
	r = len(a)
	while r - l > 1:
		m = (r + l) // 2
		if a[m] > n:
			r = m
		else:
			l = m
	return a[l]
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(0, len(a)):
	b.append([a[i], i + 1])
a = b
l = -1
r = n + 1
max1 = 0
while r - l > 1:
	m = (r + l) // 2
	if check(m, a, s)[0] == True:
		l = m
		max1 = check(m, a, s)[1]
	else:
		r = m
print(l, max1)


from bisect import bisect_left

def searchCandies(a, n, suma, mo):
	(l, h, m, ans) = (1, n, 0, [0, 0])
	while l <= h:
		(m, s, b) = (l + (h - l) // 2, 0, [0] * n)
		for i in range(n):
			b[i] = a[i] + (i + 1) * m
		b.sort()
		for i in range(m):
			s += b[i]
		if s <= suma:
			ans = [m, s] if ans[0] < m else ans
			l = m + 1
		else:
			h = m - 1
	return ans

def main():
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(' '.join(list(map(str, searchCandies(a, n, s, sum(a))))))
main()


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
(low, high) = (0, n + 1)
ans = [0, 0]
b = [0] * n

def canWeBuyTillMid(arr, k):
	ans = 0
	for i in range(n):
		b[i] = arr[i] + (i + 1) * k
	b.sort()
	for i in range(k):
		ans += b[i]
	return ans
while low < high - 1:
	mid = (low + high) // 2
	sumTillMid = canWeBuyTillMid(arr, mid)
	if sumTillMid <= s:
		ans = [mid, sumTillMid]
		low = mid
	else:
		high = mid
print(ans[0], ans[1])


def cnt(arr, n, mid):
	costs = [arr[i] + (i + 1) * mid for i in range(n)]
	costs.sort()
	cost = sum(costs[:mid])
	return cost

def binary_search(arr, n, s):
	(l, r) = (0, n)
	while l <= r:
		mid = l + r >> 1
		if cnt(arr, n, mid) <= s:
			l = mid + 1
		else:
			r = mid - 1
	return l - 1

def main():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	res = binary_search(a, n, s)
	print(res, cnt(a, n, res))
main()


cost = 0
(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def funcMonotonic(a, s, k):
	global cost
	costs = [a[i] + (i + 1) * k for i in range(n)]
	costs.sort()
	cost = sum(costs[:k])
	return cost <= s
(left, right) = (0, n + 1)
while left + 1 < right:
	middle = (left + right) // 2
	if funcMonotonic(a, s, middle):
		left = middle
	else:
		right = middle
funcMonotonic(a, s, left)
print(left, cost)


(n, mm) = list(map(int, input().split()))
ar = list(map(int, input().split()))
pr = list(ar)

def check(curr):
	for i in range(0, n):
		pr[i] = ar[i] + curr * (i + 1)
	pr.sort()
	return sum(pr[0:curr])

def BS(l, r):
	if r == l + 1:
		if check(r) <= mm:
			return r
		return l
	m = l + r
	m = m // 2
	if check(m) <= mm:
		return BS(m, r)
	return BS(l, m)
ans = BS(0, n)
print(ans, end=' ')
print(check(ans))


(n, S) = map(int, input().split())
l = list(map(int, input().split()))
(l2, r) = (0, n)
v = 0
while l2 != r:
	l1 = []
	m = (l2 + r + 1) // 2
	for i in range(n):
		l1.append(l[i] + (i + 1) * m)
	l1 = sorted(l1)
	for i in range(1, n):
		l1[i] += l1[i - 1]
	if l1[m - 1] > S:
		r = m - 1
	else:
		l2 = m
		v = l1[m - 1]
print(l2, v)


(n, s) = map(int, input().split())
v = list(map(int, input().split()))
r = n + 1
l = 0
o = 0
while r - l != 1:
	s1 = s
	b = []
	t = True
	for i in range(n):
		b.append(v[i] + (i + 1) * ((r + l) // 2))
	b.sort()
	i = 0
	sum = 0
	for i in range((r + l) // 2):
		sum += b[i]
	if sum <= s:
		l = (r + l) // 2
		o = sum
	else:
		r = (r + l) // 2
	s = s1
print(l, o)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, s) = M()
a = L()

def check(k, s):
	l = a[:]
	for i in range(len(l)):
		l[i] += k * (i + 1)
	l.sort()
	w = sum(l[:k])
	if w <= s:
		return (True, w)
	else:
		return (False, 0)
le = 0
r = n
d = 0
t = 0
while le <= r:
	mid = (le + r) // 2
	(p, q) = check(mid, s)
	if p:
		le = mid + 1
		d = mid
		t = q
	else:
		r = mid - 1
print(d, t)


import sys
(n, S) = tuple(map(int, sys.stdin.readline().split(' ')))
baseCosts = list(map(int, sys.stdin.readline().split(' ')))

def costTaking(k: int) -> int:
	costs = list(map(lambda tup: tup[1] + (tup[0] + 1) * k, enumerate(baseCosts)))
	sortedCosts = sorted(costs)
	return sum(sortedCosts[0:k])
left = 0
right = n + 1
while left < right:
	mid = (left + right) // 2
	if costTaking(mid) > S:
		right = mid
	else:
		left = mid + 1
print(right - 1, costTaking(right - 1))


def f(k, a: [int]):
	b = [0] * len(a)
	for i in range(len(a)):
		b[i] = a[i] + (i + 1) * k
	b.sort()
	ans = 0
	for i in range(k):
		ans += b[i]
	return ans

def main():
	(n, S) = map(int, input().split())
	a = list(map(int, input().split()))
	l = 0
	r = n
	while True:
		k = (r - l) // 2 + l
		T = f(k, a)
		if T > S:
			r = k - 1
		elif k == n:
			print(k, T)
			break
		else:
			T2 = f(k + 1, a)
			if T2 > S:
				print(k, T)
				break
			else:
				l = k + 1
main()


(n, S) = map(int, input().split())
a = [int(x) for x in input().split()]

def calc(k):
	prices = [a[i] + (i + 1) * k for (i, x) in enumerate(a)]
	prices.sort()
	return sum(prices[:k])
(l, r) = (0, n)
while l != r:
	m = (l + r + 1) // 2
	if calc(m) <= S:
		l = m
	else:
		r = m - 1
print(l, calc(l))


def getCost(n, k, a):
	cost = [a[i] + k * (i + 1) for i in range(n)]
	cost.sort()
	return sum(cost[:k])
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = n + 1
temp = 0
ans = 0
while l < r - 1:
	m = (l + r) // 2
	temp = getCost(n, m, a)
	if temp <= s:
		ans = temp
		l = m
	else:
		r = m
print(l, ans)


from collections import Counter, defaultdict, deque
import heapq as hq
import math
import sys
input = sys.stdin.readline

def check(k):
	global arr, n, s
	newarr = []
	for i in range(n):
		newarr.append(arr[i] + (i + 1) * k)
	newarr.sort()
	return s >= sum(newarr[:k])
(n, s) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
left = 0
right = n
while left <= right:
	mid = (left + right) // 2
	if check(mid):
		left = mid + 1
	else:
		right = mid - 1
newarr = []
for i in range(n):
	newarr.append(arr[i] + (i + 1) * right)
newarr.sort()
print(right, sum(newarr[:right]))


def check(arr, k):
	arr1 = arr[:]
	for i in range(n):
		arr1[i] = arr1[i] + (i + 1) * k
	arr1 = sorted(arr1)
	return sum(arr1[:k])
(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
l = 1
r = n
(ans1, ans2) = (0, int(2000000000.0))
while l <= r:
	mid = (l + r) // 2
	cost = check(arr, mid)
	if cost <= s and mid > ans1:
		(ans1, ans2) = (mid, cost)
		l = mid + 1
	else:
		r = mid - 1
print(ans1, end=' ')
if ans2 == int(2000000000.0):
	print(0)
else:
	print(ans2)


(n, s) = map(int, input().split())
prices = list(map(int, input().split()))
l = 0
r = n
realvalue = 0
realmid = 0
mid = 0
while l <= r:
	mid = l + (r - l) // 2
	value = 0
	b = []
	for i in range(n):
		b.append(prices[i] + (i + 1) * mid)
	b.sort()
	for i in range(mid):
		value += b[i]
	if value <= s:
		realmid = mid
		realvalue = value
	if s <= value:
		r = mid - 1
	else:
		l = mid + 1
print(realmid, realvalue)


import sys
input = sys.stdin.readline

def check(k, money):
	aux = []
	for i in range(n):
		aux.append(l[i] + (i + 1) * k)
	aux.sort()
	ans = [0, 0]
	if ans[0] == k:
		return ans
	for e in aux:
		if money - e < 0:
			break
		ans[0] += 1
		ans[1] += e
		if ans[0] == k:
			break
		money -= e
	if ans[0] < k:
		ans[0] = -1
	return ans
for _ in range(1):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	low = 0
	high = n
	g = [0, 0]
	while low <= high:
		mid = low + (high - low) // 2
		ans = check(mid, s)
		if ans[0] == mid:
			g = ans
			low = mid + 1
		else:
			high = mid - 1
	print(*g)


vals = input().split()
n = int(vals[0])
S = int(vals[1])
vals = input().split()
a = [int(val) for val in vals]
size = len(a)
l = 0
r = size - 1
ans1 = 0
ans2 = 0
while l <= r:
	mid = l + (r - l) // 2
	d = [x + (index + 1) * (mid + 1) for (index, x) in enumerate(a)]
	d.sort()
	sum = 0
	for i in range(mid + 1):
		sum += d[i]
	if sum > S:
		r = mid - 1
	else:
		ans1 = mid + 1
		ans2 = sum
		l = mid + 1
print(ans1, ans2)


import sys

def sol(k):
	B = [0] * n
	for i in range(n):
		B[i] = A[i] + k * (i + 1)
	B.sort()
	res = 0
	for i in range(k):
		res += B[i]
	return res
(n, s) = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
l = 0
r = n + 1
while l < r - 1:
	mid = (l + r) // 2
	if sol(mid) <= s:
		l = mid
	else:
		r = mid
print(l, sol(l))


def market(li, S):
	start = 0
	end = len(li)
	ans = -1
	new = [0 for v in range(len(li))]
	while start <= end:
		mid = (start + end) // 2
		arr = [0 for b in range(mid)]
		if ispossible(mid, S, li, new) is True:
			ans = mid
			start = mid + 1
		else:
			end = mid - 1
	return ans

def ispossible(k, S, li, new):
	for q in range(len(li)):
		new[q] = li[q] + (q + 1) * k
	new.sort()
	total = 0
	for i in range(0, k):
		total = total + new[i]
	if total <= S:
		return True
	else:
		return False
li1 = [int(x) for x in input().split()]
S = li1[1]
li = [int(x) for x in input().split()]
a = market(li, S)
summ = 0
final = [0 for c in range(len(li))]
for i in range(len(li)):
	final[i] = li[i] + (i + 1) * a
final.sort()
for y in range(a):
	summ = summ + final[y]
print(a, end=' ')
print(summ)


import sys
import math
import copy
(n, budget) = [int(x) for x in sys.stdin.readline().strip().split(' ')]
items = [int(x) for x in sys.stdin.readline().strip().split(' ')]

def money(k):
	cursum = 0
	computed = []
	for i in range(0, len(items)):
		cur = (i + 1) * k + items[i]
		computed.append(cur)
	computed = sorted(computed)
	for i in range(0, k):
		cursum += computed[i]
	return cursum

def compute(k):
	cursum = money(k)
	if cursum <= budget:
		return True
	else:
		return False
low = 0
high = len(items)
while low != high:
	guess = math.ceil((low + high) / 2)
	if compute(guess):
		low = guess
	else:
		high = guess - 1
print(low, money(low))


def good(k):
	newp = []
	for i in range(len(prices)):
		newp.append(prices[i] + (i + 1) * k)
	newp.sort()
	mincosts[k] = sum(newp[:k])
	return mincosts[k] <= s

def binsearch():
	l = 0
	r = n + 1
	while r - l > 1:
		m = (l + r) // 2
		if good(m):
			l = m
		else:
			r = m
	if r < n + 1 and good(r):
		return r
	return l
(n, s) = map(int, input().split())
prices = list(map(int, input().split()))
mincosts = [0 for i in range(n + 1)]
b = binsearch()
print(b, mincosts[b])


(n, S) = map(int, input().split())
a = list(map(int, input().split()))
(l, r, m, cost) = (0, n + 1, -1, -1)
while r - l > 1:
	m = (l + r) // 2
	cost = sum(sorted([a[i] + (i + 1) * m for i in range(n)])[:m])
	(l, r) = (l, m) if cost > S else (m, r)
print(l, sum(sorted([a[i] + (i + 1) * l for i in range(n)])[:l]))


(n, S) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = n
realValue = 0
realMid = 0
mid = 0
while l <= r:
	mid = l + (r - l) // 2
	value = 0
	b = []
	for i in range(n):
		b.append(a[i] + (i + 1) * mid)
	b = sorted(b)
	for i in range(mid):
		value += b[i]
	if value <= S:
		realMid = mid
		realValue = value
	if S <= value:
		r = mid - 1
	else:
		l = mid + 1
if realValue > S:
	print('0 0')
else:
	print(realMid, realValue)


import random, math
from copy import deepcopy as dc

def randomNumber(s, e):
	return random.randint(s, e)

def randomArray(s, e, s_size, e_size):
	size = random.randint(s_size, e_size)
	arr = [randomNumber(s, e) for i in range(size)]
	return arr

def testcase():
	pass

def brute():
	pass

def effe():
	pass

def f(li, c):
	if c > len(li):
		c = len(li)
	pri = []
	for i in range(len(li)):
		pri.append(li[i] + c * (i + 1))
	pri.sort()
	s = 0
	for i in range(c):
		s += pri[i]
	return s

def solution(li, s):
	l = 0
	r = len(li)
	while l <= r:
		mid = (l + r) // 2
		out = f(li, mid)
		out1 = f(li, mid + 1)
		if out <= s and out1 > s:
			return [mid, out]
		elif out > s:
			r = mid - 1
		else:
			l = mid + 1
	return [mid, out]

def input_test():
	(n, s) = map(int, input().strip().split(' '))
	li = list(map(int, input().strip().split(' ')))
	out = solution(li, s)
	print(' '.join(map(str, out)))

def test():
	pass
input_test()


(n, S) = map(int, input().split())
st = input().split(' ')
cost = [int(num) for num in st]
(l, r, Smin, k) = (0, n + 1, 0, 0)
for _ in range(20):
	k = int((l + r) / 2)
	a = list()
	for i in range(n):
		a.append(cost[i] + k * (i + 1))
	a.sort()
	s = 0
	for i in range(k):
		s += a[i]
	if s <= S:
		l = k
		Smin = s
	else:
		r = k
print(k, int(Smin))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def MoneyNeeded(k):
	effective = sorted([k * (i + 1) + costs[i] for i in range(n)])
	return sum(effective[:k])
(n, money) = value()
costs = array()
low = 0
high = n
while low <= high:
	mid = (low + high) // 2
	cost = MoneyNeeded(mid)
	if cost <= money:
		ans = (mid, cost)
		low = mid + 1
	else:
		high = mid - 1
print(*ans)


(n, S) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
(l, r) = (1, n)
(ans_k, ans_cost) = (0, 0)
while l <= r:
	k = int((l + r) / 2)
	cost = [a[i] + (i + 1) * k for i in range(n)]
	cost = sorted(cost)
	cost_sum = sum(cost[:k])
	if cost_sum <= S:
		ans_k = k
		ans_cost = cost_sum
		l = k + 1
	else:
		r = k - 1
print('{} {}'.format(ans_k, ans_cost))


(n, b) = map(int, input().split())
a = list(map(int, input().split()))
(l, h) = (0, n)

def s(m):
	x = sum(sorted([a[i] + (i + 1) * m for i in range(n)])[:m])
	return 0 if x > b else x
while l < h:
	m = (l + h + 1) // 2
	if s(m):
		l = m
	else:
		h = m - 1
print(l, s(l))


def arr_enu():
	return list([[i + 1, int(x)] for (i, x) in enumerate(stdin.readline().split())])

def calculate(x):
	tem = []
	for i in range(n):
		tem.append(a[i][1] + a[i][0] * x)
	tem.sort()
	s = sum(tem[:x])
	return s

def bs():
	global ans
	(en, be) = (n, 0)
	while be <= en:
		mid = (be + en) // 2
		val = calculate(mid)
		if val <= s1:
			be = mid + 1
			if mid > ans[0]:
				ans = [mid, val]
		else:
			en = mid - 1
from sys import stdin
from itertools import accumulate
from collections import *
(n, s1) = map(int, input().split())
(a, ans) = (arr_enu(), [0, 0])
bs()
print(*ans)


(n, c) = map(int, input().split())
items = list(map(int, input().split()))
global oldCost
global oldm
cost = [0] * n

def calc_cost(m):
	sum_to_m = 0
	for i in range(n):
		cost[i] = items[i] + (i + 1) * m
	cost.sort()
	for i in range(m):
		sum_to_m += cost[i]
	return sum_to_m
l = 0
r = n
m = 0
while l <= r:
	m = (l + r) // 2
	a = calc_cost(m)
	if a <= c:
		oldCost = a
		oldm = m
		l = m + 1
	else:
		r = m - 1
print(oldm, oldCost)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def find_max(k):
	s = [a[i] + (i + 1) * k for i in range(n)]
	s.sort()
	f = sum(s[:k])
	if f > m:
		return 0
	else:
		return f
(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
v = 0
(l, r) = (0, n)
while l < r:
	k = (l + r) // 2
	if l == k:
		break
	z = find_max(k)
	if z:
		v = z
		l = k
	else:
		r = k
last = find_max(n)
if last <= m and last != 0:
	l = n
	v = last
print(l, v)


def proverka(k, a, s):
	b = []
	for i in a:
		b.append(i)
	for i in range(len(b)):
		b[i] = b[i] + k * (i + 1)
	b.sort()
	cnt = 0
	index = 0
	while cnt < k and s - b[index] >= 0:
		cnt += 1
		s -= b[index]
		index += 1
	if cnt < k:
		return False
	else:
		return True
(n, s) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
r = n + 1
while l + 1 < r:
	if proverka((l + r) // 2, a, s):
		l = (l + r) // 2
	else:
		r = (l + r) // 2
for i in range(n):
	a[i] = a[i] + l * (i + 1)
a.sort()
qwer = 0
index = 0
while index < l and qwer + a[index] <= s:
	qwer += a[index]
	index += 1
print(l, qwer)


def check(k, a, n):
	res = 0
	c = []
	for i in range(0, n):
		c.append(a[i] + (i + 1) * k)
	c.sort()
	for i in range(0, k):
		res += c[i]
	return res
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
l = 1
r = n
tot = 0
ans = 0
while l <= r:
	mid = int((l + r) / 2)
	x = check(mid, a, n)
	if x <= s:
		tot = mid
		ans = x
		l = mid + 1
	else:
		r = mid - 1
print(tot, ans)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def cout(x):
	b = list(a)
	for (i, y) in enumerate(b):
		b[i] = (i + 1) * x + y
	b.sort()
	return sum(b[:x])
(i, j) = (0, n + 1)
while i + 1 < j:
	mid = (i + j) // 2
	if cout(mid) <= s:
		i = mid
	else:
		j = mid
result = cout(i)
if result > s:
	print(0, 0)
else:
	print(i, result)


def main():
	(n, s) = map(int, input().split())
	aa = list(map(int, input().split()))
	(lo, hi) = (0, n)
	helper = lambda e: sum(sorted((i * e + a for (i, a) in enumerate(aa, 1)))[:e])
	while lo < hi:
		mid = (lo + hi + 1) // 2
		t = helper(mid)
		if s < t:
			hi = mid - 1
		else:
			lo = mid
	print(lo, helper(lo))
main()


from math import inf
(n, s) = map(int, input().split())
a = [int(x) for x in input().split()]
p = 1
q = n
suv_num = inf
best_cost = inf
while p <= q:
	mid = (p + q) // 2
	costs = a[:]
	for (index, cost) in enumerate(costs):
		costs[index] = cost + mid * (index + 1)
	costs.sort()
	tmp_sum = sum(costs[:mid])
	if tmp_sum <= s:
		best_cost = tmp_sum
		suv_num = mid
		p = mid + 1
	else:
		q = mid - 1
if suv_num != inf:
	print(suv_num, best_cost)
else:
	print(0, 0)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(l, r, res) = (0, n, 0)
while l <= r:
	m = (l + r) // 2
	f = sorted([a[i] + (i + 1) * m for i in range(n)])
	g = sum(f[:m])
	if g <= s:
		(l, res) = (m + 1, g)
	else:
		r = m - 1
print(l - 1, res)


R = lambda : map(int, input().split())
(n, S) = R()
a = list(R())
(l, r, s) = (0, n, 0)
while l < r:
	m = (l + r + 1) // 2
	t = sum(sorted((x + (i + 1) * m for (i, x) in enumerate(a)))[:m])
	if t <= S:
		l = m
		s = t
	else:
		r = m - 1
print(l, s)


from bisect import bisect_left
(n, S) = map(int, input().split())
a = list(map(int, input().split()))

def ok(k):
	return getPrice(k) <= S

def getPrice(k):
	price = sorted((i + (idx + 1) * k for (idx, i) in enumerate(a)))
	return sum(price[:k])

class LazyEval(list):

	def __init__(self, n):
		self.l = [100] * n

	def __getitem__(self, i):
		if self.l[i] == 100:
			self.l[i] = -int(ok(i))
		return self.l[i]

	def __len__(self):
		return len(self.l)
l = LazyEval(n + 1)
best_idx = bisect_left(l, 0)
print(best_idx - 1, getPrice(best_idx - 1))


def check(A, S, k):
	prices = []
	for (i, a) in enumerate(A):
		prices.append(a + (i + 1) * k)
	prices.sort()
	total = sum(prices[:k])
	return (total <= S, total)
(n, S) = map(int, input().split())
A = [int(a) for a in input().split()]
k = -1
p = 0
skip = n
while skip >= 1:
	while k + skip <= n and check(A, S, k + skip)[0]:
		p = check(A, S, k + skip)[1]
		k += skip
	skip //= 2
print(k, p)


(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
l = 0
r = n
mxnumber = 0
mincost = 0
while l <= r:
	mid = l + (r - l) // 2
	b = []
	value = 0
	for i in range(n):
		b.append(arr[i] + (i + 1) * mid)
	b.sort()
	for i in range(mid):
		value += b[i]
	if value <= s:
		mxnumber = mid
		mincost = value
	if s <= value:
		r = mid - 1
	else:
		l = mid + 1
print(mxnumber, mincost)


def getCost(a, k):
	b = a.copy()
	for i in range(0, len(a)):
		b[i] += k * (i + 1)
	b.sort()
	cost = 0
	for i in range(0, int(k)):
		cost += b[i]
	return cost
(n, s) = list(map(int, input().split()))
a = list(map(int, input().split()))
left = 0
right = n
num = 0
spent = 0
while left <= right:
	mid = int(left + right) // 2
	cost = getCost(a, mid)
	if cost <= s:
		left = mid + 1
		num = mid
		spent = cost
	else:
		right = mid - 1
print(num, ' ', spent)


(n, s) = list(map(int, input().split()))
a = list(map(int, input().split()))
st = 1
end = n
ans = -1
while st <= end:
	k = (st + end) // 2
	b = []
	for i in range(n):
		b.append(a[i] + (i + 1) * k)
	b.sort()
	d = sum(b[:k])
	if d == s:
		ans = k
		break
		end = k - 1
	elif d > s:
		end = k - 1
	else:
		st = k + 1
if ans == -1:
	if sum(b[:k]) > s:
		b = []
		for i in range(n):
			b.append(a[i] + (i + 1) * (k - 1))
		b.sort()
		print(k - 1, sum(b[:k - 1]))
	else:
		print(k, sum(b[:k]))
else:
	print(ans, d)


(n, s) = map(int, input().strip().split())
t = input()
a = list(map(int, t.strip().split()))

def check(x):
	b = []
	for i in range(n):
		temp = (i + 1) * x + a[i]
		b.append(temp)
	b.sort()
	sum = 0
	x = int(x)
	for i in range(x):
		sum += b[i]
	if sum <= s:
		return (1, sum)
	else:
		return (0, sum)
L = 1
R = n
ans = 0
sum = 0
ans1 = 0
while L <= R:
	mid = int((L + R) / 2)
	(temp, sum) = check(mid)
	if temp == 0:
		R = mid - 1
	else:
		L = mid + 1
		ans = mid
		ans1 = sum
print(ans, end=' ')
print(ans1)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, S) = ria()
		a = ria()
		mincost = [0]

		def possible(k):
			prices = []
			for i in range(n):
				prices.append(a[i] + (i + 1) * k)
			prices = sorted(prices)
			mc = sum(prices[:k])
			if mc <= S:
				mincost[0] = mc
				return True
			else:
				return False
		l = 0
		r = n
		ans = 0
		while l <= r:
			mid = (l + r) // 2
			if possible(mid):
				ans = mid
				l = mid + 1
			else:
				r = mid - 1
		print(ans, *mincost)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


(n, S) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
(lo, hi) = (0, n + 1)
while lo < hi:
	mid = (lo + hi) // 2
	if mid > n:
		hi = mid
		continue
	if sum(sorted((x + (i + 1) * mid for (i, x) in enumerate(a)))[:mid]) <= S:
		lo = mid + 1
	else:
		hi = mid
lo -= 1
print(lo, sum(sorted((x + (i + 1) * lo for (i, x) in enumerate(a)))[:lo]))


def calc(cnt):
	return sum(sorted((num + cnt * ind for (ind, num) in enumerate(price, 1)))[:cnt])
(n, money) = map(int, input().split())
price = [int(num) for num in input().split()]
can = 0
cant = n + 1
while cant - can > 1:
	mid = (can + cant) // 2
	if calc(mid) <= money:
		can = mid
	else:
		cant = mid
print(can, calc(can))


(n, S) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []
k = S
t = False

def Merge(array):
	if len(array) == 1:
		return
	else:
		R = array[len(array) // 2:]
		L = array[:len(array) // 2]
		Merge(R)
		Merge(L)
	i = j = k = 0
	while i < len(R) and j < len(L):
		if R[i] < L[j]:
			array[k] = R[i]
			i += 1
			k += 1
		else:
			array[k] = L[j]
			j += 1
			k += 1
	while j < len(L):
		array[k] = L[j]
		j += 1
		k += 1
	while i < len(R):
		array[k] = R[i]
		i += 1
		k += 1

def KK(lower, upper):
	global new_k, b, t, n
	new_k = (lower + upper) // 2
	if new_k == lower or new_k == upper:
		if t:
			if new_k > n:
				new_k = n
				b = list(a)
				for po in range(1, len(b) + 1):
					b[po - 1] = b[po - 1] + new_k * po
				Merge(b)
			print(new_k, sum(b[:new_k:1]), sep=' ')
			return
		t = True
	b = list(a)
	for po in range(1, len(b) + 1):
		b[po - 1] = b[po - 1] + new_k * po
	Merge(b)
	if sum(b[:new_k]) <= S:
		KK(new_k, upper)
	else:
		KK(lower, new_k)
KK(0, k)


from itertools import count
(n, m) = list(map(int, input().split()))
p = [int(num) for num in input().split()]

def calc(cnt):
	new_p = list(map(lambda ind, num: num + cnt * ind, count(1), p))
	return sum(sorted(new_p)[:cnt])

def can(cnt):
	return calc(cnt) <= m
l = 0
r = n + 1
while r - l > 1:
	mid = (l + r) // 2
	if can(mid):
		l = mid
	else:
		r = mid
print(l, calc(l))


(n, s) = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]
sum = 0

def chkProcess(k):
	map1 = []
	sumx = 0
	for i in range(1, n + 1):
		map1.append(array[i - 1] + i * k)
	map1 = sorted(map1)
	for i in range(k):
		sumx += map1[i]
	return sumx
(upper, lower) = (0, n + 1)
while upper < lower - 1:
	mid = (upper + lower) // 2
	sumx = chkProcess(mid)
	if sumx <= s:
		upper = mid
	else:
		lower = mid
print(upper, chkProcess(upper))


from sys import stdin as fin
(n, S) = map(int, fin.readline().split())
arr = list(map(int, fin.readline().split()))

def test(k):
	nonlocal arr, n, S
	costs = sorted([arr[i] + (i + 1) * k for i in range(n)])
	csum = sum(costs[:k])
	if csum <= S:
		return csum
	else:
		return 0
(l, r, m) = (0, n + 1, 0)
(ans, ansm) = (0, 0)
while l + 1 != r:
	m = (l + r) // 2
	csum = test(m)
	if not csum:
		r = m
	else:
		ans = csum
		ansm = m
		l = m
print(ansm if ans else 0, ans)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def find(k):
	b = [(i + 1) * k + a[i] for i in range(n)]
	b = sorted(b)
	return sum(b[:k])
(l, r) = (0, n)
ans = 0
while l < r:
	md = (l + r + 1) // 2
	ans = find(md)
	if ans <= s:
		l = md
	else:
		r = md - 1
print(l, find(l))


(n, s) = list(map(int, input().split()))
nums = list(map(int, input().split()))

def findcost(k):
	prices = [nums[i] + k * (i + 1) for i in range(n)]
	prices.sort()
	return sum(prices[:k])
(low, high) = (0, n)
(ans, cos) = (0, 0)
while low <= high:
	mid = (low + high) // 2
	cost = findcost(mid)
	if cost > s:
		high = mid - 1
	else:
		low = mid + 1
		ans = mid
		cos = cost
print(ans, cos)


def f(m):
	ijk = sorted([arr[i] + m * (i + 1) for i in range(n)])
	return sum(ijk[:m])
(n, S) = map(int, input().split())
arr = list(map(int, input().split()))
(lo, hi) = (0, n)
while lo < hi:
	mid = (lo + hi + 1) // 2
	if f(mid) <= S:
		lo = mid
	else:
		hi = mid - 1
print(lo, f(lo))


def budget(o, data):
	coast = 0
	arr = []
	for i in range(len(data)):
		arr.append((i + 1) * o + data[i])
	arr = sorted(arr)
	for j in range(o):
		coast += arr[j]
	return coast

def getTotalItems(mid, data, money):
	total = 0
	for i in range(mid):
		total += (i + 1) * mid + data[i]
	if total <= money:
		return True
	else:
		for j in range(mid, len(data)):
			total -= (j - mid + 1) * mid + data[j - mid]
			total += (j + 1) * mid + data[j]
			if total <= money:
				return True
	return False

def bsItems(data, mon):
	r = len(data)
	l = 0
	money = mon
	lCoast = 0
	while r - l > 0:
		m = (l + r + 1) // 2
		if budget(m, data) > money:
			r = m - 1
		else:
			l = m
	minmumCoast = budget(l, data)
	return (l, minmumCoast)

def getMinTotalCoast(data, mi, money, items2):
	total2 = mi
	n2 = len(data)
	print(f'm is {mi}')
	for i in range(items2):
		total2 -= (i + 1) * items2 + data[i]
	if total2 >= 0:
		return True
	else:
		print(total2)
		for j in range(items2, n2):
			indx = j - items2
			total2 += (indx + 1) * items2 + data[indx]
			print(total2)
			total2 -= (j + 1) * items2 + data[j]
			print(total2)
			if total2 >= 0:
				return True
	return False

def bsTotalCoast(data, money, items2):
	r = money
	l = 0
	while r - l > 0:
		min_coast = (l + r) // 2
		if getMinTotalCoast(data, min_coast, money, items2):
			r = min_coast
		else:
			l = min_coast + 1
	return r
(n, s) = map(int, input().split(' '))
items = list(map(int, input().split(' ')))
(k, t) = bsItems(items, s)
print(k, t, end=' ')


import sys
import math
import collections
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 10

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def fun(m):
	cnt = 0
	b = [a[i] + m * (i + 1) for i in range(n)]
	b.sort()
	for i in range(m):
		cnt += b[i]
	return [cnt <= s, cnt]
(l, h, ans, cost) = (0, n, 0, 0)
while l <= h:
	m = (l + h) // 2
	temp = fun(m)
	if temp[0]:
		ans = m
		cost = temp[1]
		l = m + 1
	else:
		h = m - 1
print('%d %d' % (ans, cost))


def bSearch(left, right, money, a):
	if right == left:
		if canBuy(left, money, a) != -1:
			print(left, canBuy(left, money, a))
			return left
	if right - 1 == left:
		if canBuy(right, money, a) != -1:
			print(right, canBuy(right, money, a))
			return right
		if canBuy(left, money, a) != -1:
			print(left, canBuy(left, money, a))
			return left
	mid = (right + left) // 2
	if canBuy(mid, money, a) != -1:
		return bSearch(mid, right, money, a)
	else:
		return bSearch(left, mid - 1, money, a)
	return -1

def canBuy(k, m, x):
	arr = x[:]
	s = 0
	for i in range(len(arr)):
		arr[i] += k * (i + 1)
	arr.sort()
	s = sum(arr[:k])
	if s <= m:
		return s
	return -1
(n, money) = input('').split(' ')
(n, money) = (int(n), int(money))
prices = [int(x) for x in input('').split(' ')]
bSearch(0, n, money, prices)


def check(k):
	anew = [a[i] + (i + 1) * k for i in range(n)]
	anew.sort()
	asum = sum(anew[:k])
	if asum <= s:
		return asum
	else:
		return 0
(n, s) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
min_sum = 0
L = 0
R = n + 1
while R - L > 1:
	m = (L + R) // 2
	res = check(m)
	if res:
		L = m
		min_sum = res
	else:
		R = m
print(L, min_sum)


import sys
(n, s) = map(int, sys.stdin.readline().split())
l = list(map(int, sys.stdin.readline().split()))
t = list(map(lambda x: x[1] + n * (x[0] + 1), enumerate(l)))
upper = n - 1
lower = 0
while upper > lower:
	k = (upper + lower) // 2
	t = list(map(lambda x: x[1] + k * (x[0] + 1), enumerate(l)))
	h = sum(sorted(t)[:k])
	if h == s:
		break
	if h < s:
		lower = k + 1
	else:
		upper = k - 1
t = list(map(lambda x: x[1] + upper * (x[0] + 1), enumerate(l)))
if sum(sorted(t)[:upper]) <= s:
	z = list(map(lambda x: x[1] + (upper + 1) * (x[0] + 1), enumerate(l)))
	if sum(sorted(z)[:upper + 1]) < s:
		print(upper + 1, sum(sorted(z)[:upper + 1]))
	else:
		print(upper, sum(sorted(t)[:upper]))
else:
	t = list(map(lambda x: x[1] + (upper - 1) * (x[0] + 1), enumerate(l)))
	print(upper - 1, sum(sorted(t)[:upper - 1]))


def newArr(a, k):
	b = a
	i = 0
	n = len(a)
	while i < n:
		b[i] += (i + 1) * k
		i += 1
	return b

def minSum(a, k):
	a.sort()
	sm = 0
	cnt = 0
	i = 0
	while i < k:
		sm += a[i]
		i += 1
	return sm
inp = input().split()
n = int(inp[0])
S = int(inp[1])
inp = input().split()
a = []
for x in inp:
	a.append(int(x))
l = 0
r = n
while l < r:
	mid = (l + r) // 2
	if l + 1 == r:
		mid = r
	b = newArr(list(a), mid)
	if minSum(b, mid) <= S:
		l = mid
	else:
		r = mid - 1
ans = l
print(str(ans) + ' ' + str(minSum(newArr(a, ans), ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def good(mid, a):
	ans = []
	for i in range(0, len(a)):
		ans.append(a[i] + (i + 1) * mid)
	ans.sort()
	sumi = 0
	for i in range(0, mid):
		sumi += ans[i]
	return sumi
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = n
ans = 0
sumi = 0
while l <= r:
	mid = (l + r) // 2
	if good(mid, a) <= s:
		sumi = good(mid, a)
		l = mid + 1
		ans = mid
	else:
		r = mid - 1
print(ans, sumi)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def cost(p):
	r = [a[i] + p * (i + 1) for i in range(n)]
	r.sort()
	t = sum(r[:p])
	return t
l = 0
e = n + 1
while l < e - 1:
	m = (l + e) // 2
	if cost(m) <= s:
		l = m
	else:
		e = m
print(l, cost(l))


import heapq

def canbuy(n, A, k, s):
	q = []
	for i in range(n):
		x = A[i] + (i + 1) * k
		heapq.heappush(q, x)
	count = 0
	cost = 0
	while count < k:
		cost += heapq.heappop(q)
		count += 1
	if cost <= s:
		return (True, cost)
	return (False, cost)

def answer(n, s, A):
	l = 0
	r = n
	ans = -1
	cost_g = -1
	while r >= l:
		mid = (l + r) // 2
		(check, cost_c) = canbuy(n, A, mid, s)
		if check:
			ans = mid
			cost_g = cost_c
			l = mid + 1
		else:
			r = mid - 1
	if ans == -1:
		return [0, 0]
	return [ans, cost_g]
(n, s) = map(int, input().split())
arr = list(map(int, input().split()))
print(*answer(n, s, arr))


(n, s) = [int(i) for i in input().split()]
ll = [int(i) for i in input().split()]
curr = 0
l = 0
h = n
while l <= h:
	mid = (h + l) // 2
	k = ll[:]
	for i in range(n):
		k[i] = (i + 1) * mid + ll[i]
	k.sort()
	sm = sum(k[:mid])
	if sm <= s:
		curr = mid
		l = mid + 1
		ans = sm
	else:
		h = mid - 1
print(curr, ans)


(n, S) = map(int, input().strip().split())
A = list(map(int, input().strip().split()))

def cost(k):
	if k == 0:
		return 0
	costs = []
	for i in range(n):
		costs.append(A[i] + (i + 1) * k)
	costs = sorted(costs)
	return sum(costs[:k])

def cls():
	l = 0
	r = n + 1
	while l < r - 1:
		m = (l + r) // 2
		if cost(m) <= S:
			l = m
		else:
			r = m
	print(l, cost(l))
cls()


def f(k):
	cur = sum(sorted([a[i] + (i + 1) * k for i in range(n)])[:k])
	return (cur, cur <= S)
read = lambda : map(int, input().split())
(n, S) = read()
a = list(read())
(l, r) = (0, n + 1)
while r - l > 1:
	m = l + r >> 1
	if f(m)[1]:
		l = m
	else:
		r = m
print(l, f(l)[0])


(n, S) = map(int, input().split())
a = list(map(int, input().split()))

def calc(k):
	m = [a[i] + k * (i + 1) for i in range(n)]
	m = sorted(m)
	return (sum(m[:k]) <= S, sum(m[:k]))
l = 0
r = n
while l < r:
	mid = (l + r + 1) // 2
	(f, s) = calc(mid)
	if f:
		l = mid
	else:
		r = mid - 1
(f, s) = calc(l)
print(l, s)


(n, m1) = map(int, input().split())
lp = list(map(int, input().split()))
l = 0
r = n
while l < r:
	m = (l + r + 1) // 2
	l1 = lp[:]
	for i in range(n):
		l1[i] = lp[i] + (i + 1) * m
	l1 = sorted(l1)
	s = sum(l1[:m])
	if s > m1:
		r = m - 1
	else:
		l = m
l1 = lp[:]
for i in range(n):
	l1[i] = lp[i] + (i + 1) * l
l1 = sorted(l1)
s = sum(l1[:l])
print(l, s)


(n, s) = map(int, input().split())
a = list(map(int, input().split()))

def check(m):
	ac = sorted([a[i - 1] + i * m for i in range(1, n + 1)])
	w = sum(ac[:m])
	if w <= s:
		return (True, w)
	else:
		return (False, 0)
(l, r) = (0, len(a) + 1)
last = -1
lastw = 0
while l < r:
	m = l + (r - l) // 2
	(st, w) = check(m)
	if st:
		last = m
		lastw = w
		if l == m:
			break
		l = m
	else:
		r = m
print(last, lastw)


def find(k):
	new = sorted([a[i] + (i + 1) * k for i in range(n)])
	tot = sum(new[:k])
	if tot <= s:
		return tot
	return 0
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
(low, high) = (0, n)
while low < high:
	mid = low + (high - low + 1) // 2
	if find(mid):
		low = mid
	else:
		high = mid - 1
print(low, find(low))


import sys
import bisect
from math import ceil, floor

def solve(k):
	b = []
	for i in range(n):
		b.append(a[i] + k * (i + 1))
	b.sort()
	summ = 0
	for i in range(k):
		summ += b[i]
	return summ
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7
(n, s) = RI()
a = RI()
l = 0
r = n
ansmax = -1
maxcost = 0
while l <= r:
	mid = (r + l) // 2
	temp = solve(mid)
	if temp <= s:
		if mid > ansmax:
			ansmax = max(ansmax, mid)
			maxcost = temp
		l = mid + 1
	else:
		r = mid - 1
print(ansmax, maxcost)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input()

def ans(n, k):
	b = [0] * n
	for i in range(0, n):
		b[i] = a[i] + (i + 1) * k
	b.sort()
	return sum(b[:k])
(n, s) = li()
a = li()
l = 0
r = n + 1
while l < r - 1:
	m = (l + r) // 2
	if ans(n, m) <= s:
		l = m
	else:
		r = m
print(l, ans(n, l))


def sag_nub(n, s, arr):
	N = int(n)
	S = int(s)
	(ans, total, _min, _max) = (0, 0, 0, N)
	while _min <= _max:
		b = []
		K = (_min + _max) // 2
		for i in range(N):
			b.append(int(arr[i]) + (i + 1) * K)
		b = sorted(b)
		cost = 0
		for i in range(K):
			cost += b[i]
		if cost <= S:
			ans = K
			total = cost
			_min = K + 1
		else:
			_max = K - 1
	print(str(ans) + ' ' + str(total))
(N, S) = str(input()).split(' ')
a = input().split(' ')
sag_nub(N, S, a)


import sys
from itertools import accumulate

def solve():

	def check(m):
		if m == 0:
			return 0
		b = [ai + (i + 1) * m for (i, ai) in enumerate(a)]
		b.sort()
		return sum(b[:m])
	(n, S) = map(int, input().split())
	a = [int(i) for i in input().split()]
	btm = -1
	top = n + 1
	while top - btm > 1:
		mid = (top + btm) // 2
		if check(mid) <= S:
			btm = mid
		else:
			top = mid
	k = btm
	T = check(k)
	print(k, T)
solve()


(n, s) = list(map(int, input().split()))
arr = list(map(int, input().split()))
from heapq import heapify, heappop

def buy(k):
	nonlocal n, s, arr
	if k == 0:
		return 0
	ans = 0
	temp = [arr[i - 1] + i * k for i in range(1, n + 1)]
	heapify(temp)
	for i in range(k):
		ans += heappop(temp)
	return ans

def main():
	(f, l) = (0, n)
	while f < l:
		if f == l - 1:
			(a, b) = (buy(f), buy(l))
			return (l, b) if b <= s else (f, a)
		m = (f + l) // 2
		if buy(m) <= s:
			f = m
		else:
			l = m
(a, b) = main()
print(a, b)


def main():
	(n, s) = map(int, input().split())
	a = [int(i) for i in input().split()]
	(l, r) = (0, n)
	while r - l > 1:
		mid = (l + r) // 2
		subarr = [0 for _ in range(n)]
		for i in range(n):
			subarr[i] = a[i] + (i + 1) * mid
		subarr.sort()
		pref = 0
		for i in range(mid):
			pref += subarr[i]
		if pref <= s:
			l = mid
		else:
			r = mid
	ans = -1
	subarr = [0 for _ in range(n)]
	for i in range(n):
		subarr[i] = a[i] + (i + 1) * r
	subarr.sort()
	pref = 0
	for i in range(r):
		pref += subarr[i]
	if pref <= s:
		ans = r
	else:
		ans = l
		subarr = [0 for _ in range(n)]
		for i in range(n):
			subarr[i] = a[i] + (i + 1) * l
		subarr.sort()
		pref = 0
		for i in range(l):
			pref += subarr[i]
	print(ans, pref)
main()


def getcost(m):
	summ = 0
	global n
	cost = [0 for _ in range(n)]
	for i in range(n):
		cost[i] = m * (i + 1) + a[i]
	cost.sort()
	for i in range(m):
		summ += cost[i]
	return summ
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
cost = [0] * n
summ = 0
for i in range(n):
	cost[i] = n * (i + 1) + a[i]
	summ += cost[i]
if summ <= s:
	print(n, summ)
	exit(0)
u = n
l = 0
m = 0
c = 0
cc = 0
mm = 0
while l <= u:
	m = (l + u) // 2
	c = getcost(m)
	if c <= s:
		cc = c
		mm = m
	if l == u:
		if c > s:
			c = cc
			m = mm
			break
	if c < s:
		l = m + 1
	else:
		u = m - 1
print(mm, cc)


R = lambda : list(map(int, input().split()))
(n, s) = R()
a = R()

def kill(m):
	t = sorted([a[i] + (i + 1) * m for i in range(n)])
	re = sum(t[:m])
	return 0 if re > s else re
(l, r) = (0, n)
while l < r:
	m = (l + r + 1) // 2
	if kill(m):
		l = m
	else:
		r = m - 1
print(l, kill(l))


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def fk(a, s, k):
	b = []
	for i in range(len(a)):
		b.append(a[i] + (i + 1) * k)
	b.sort()
	return sum(b[:k])
(n, s) = ma()
a = lis()
(co, mi) = (0, 0)
(l, h) = (1, n)
while l <= h:
	m = (l + h) // 2
	if fk(a, s, m) <= s:
		co = m
		mi = fk(a, s, m)
		l = m + 1
	else:
		h = m - 1
print(co, mi)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def sim(a, n, k, s):
	t = 0
	for i in range(k):
		t += a[i]
	return t
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = n
ans = 0
ans2 = 0
while l <= r:
	mid = (r + l) // 2
	seq = a.copy()
	for i in range(n):
		seq[i] = seq[i] + mid * (i + 1)
	seq.sort()
	sm = sim(seq, n, mid, s)
	if sm <= s:
		l = mid + 1
		ans = mid
		ans2 = sm
	else:
		r = mid - 1
print(ans, ans2)


import heapq
(n, S) = map(int, input().split())
a = [0] + list(map(int, input().split()))
ans = 0
(lo, hi) = (0, n)
while lo < hi:
	mid = lo + (hi - lo + 1) // 2
	a2 = []
	for i in range(len(a)):
		cur = a[i] + mid * i
		heapq.heappush(a2, cur)
	costs = [-1] * len(a2)
	total = 0
	for (i, x) in enumerate(sorted(a2)):
		total += x
		costs[i] = total
	if costs[mid] > S:
		hi = mid - 1
	else:
		lo = mid
		ans = costs[mid]
print(lo, ans)


vals = input().split()
n = int(vals[0])
S = int(vals[1])
a = [int(v) for v in input().split()]
answer1 = 0
answer2 = 0
left = 0
right = n - 1
while left <= right:
	mid = (left + right) // 2
	c = [x + (index + 1) * (mid + 1) for (index, x) in enumerate(a)]
	c.sort()
	s = sum(c[:mid + 1])
	if s == S:
		answer1 = mid + 1
		answer2 = s
		break
	elif s > S:
		right = mid - 1
	else:
		answer1 = mid + 1
		answer2 = s
		left = mid + 1
print(answer1, answer2)


from operator import itemgetter
(n, money) = list(map(int, input().split()))
costs = list(map(int, input().split()))

def binary_search():
	cost = 0
	ans = 0
	u = len(costs)
	d = 0
	while u >= d:
		mid = (u + d) // 2
		k = price(mid, n)
		if k > money:
			u = mid - 1
		elif k < money:
			d = mid + 1
			cost = k
			ans = mid
		else:
			print(mid, money)
			return
	print(ans, cost)

def price(k, n):
	b = []
	for i in range(1, n + 1):
		b.append(costs[i - 1] + i * k)
	b.sort()
	return sum(b[:k])
binary_search()


def can_buy(num, n, budget, base_costs):
	costs = [base_costs[i] + (i + 1) * num for i in range(n)]
	costs.sort()
	temp = sum(costs[:num])
	if temp <= budget:
		return (True, temp)
	else:
		return (False, 0)

def solve(n, budget, base_costs):
	start = 0
	end = n
	k = 0
	cost = 0
	while start <= end:
		mid = start + (end - start) // 2
		(check, total) = can_buy(mid, n, budget, base_costs)
		if check:
			start = mid + 1
			k = mid
			cost = total
		else:
			end = mid - 1
	return (k, cost)
(n, s) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
(k, total) = solve(n, s, a)
print(k, total)


def f(li, items):
	if items > len(li):
		items = len(li)
	price = []
	for i in range(len(li)):
		price.append(li[i] + items * (i + 1))
	price.sort()
	min_cost = 0
	for i in range(items):
		min_cost += price[i]
	return min_cost

def solution(li, amount_have):
	(l, r) = (0, len(li))
	while l <= r:
		mid = (l + r) // 2
		out = f(li, mid)
		out1 = f(li, mid + 1)
		if out <= amount_have and out1 > amount_have:
			return [mid, out]
		elif out > amount_have:
			r = mid - 1
		else:
			l = mid + 1
	return [mid, out]

def input_test():
	(n, amount_have) = map(int, input().split())
	li = [int(x) for x in input().split()]
	ans = solution(li, amount_have)
	print(' '.join(map(str, ans)))
input_test()


from heapq import *

def solution1(numItems, budget, prices):
	bag = []
	bagPrice = 0
	sumBagIndices = 0
	for (itemIndex, itemPrice) in enumerate(prices):
		itemIndex += 1
		newItemPrice = itemPrice + itemIndex * len(bag)
		newBagPrice = bagPrice + sumBagIndices + itemIndex + newItemPrice
		if newBagPrice <= budget:
			heappush(bag, [-newItemPrice, -itemIndex])
			sumBagIndices += itemIndex
			bagPrice = newBagPrice
			for i in range(len(bag)):
				bag[i][0] += bag[i][1]
			heapify(bag)
		elif bag:
			(maxBagItemPrice, maxBagPriceIndex) = (-bag[0][0], -bag[0][1])
			if newItemPrice < maxBagItemPrice:
				heapreplace(bag, [-newItemPrice, -itemIndex])
				sumBagIndices += itemIndex - maxBagPriceIndex
				bagPrice += newItemPrice - maxBagItemPrice
	print(len(bag), bagPrice)

def solution2(numItems, budget, prices):
	koptimal = 0
	poptimal = 0
	kmin = 0
	kmax = numItems
	while kmax >= kmin:
		k = (kmax + kmin) // 2
		price = sum(sorted((prices[i] + k * (i + 1) for i in range(numItems)))[:k])
		if price <= budget:
			if koptimal < k:
				(koptimal, poptimal) = (k, price)
			if price == budget:
				break
			kmin = k + 1
		elif price > budget:
			kmax = k - 1
	print(koptimal, poptimal)
(numItems, budget) = map(int, input().split())
prices = list(map(int, input().split()))
solution1(numItems, budget, prices)


def check(n, s, f):
	a = []
	for i in range(len(l)):
		a.append(l[i] + n * (i + 1))
	a.sort()
	return sum(a[0:n]) <= s if f == 1 else sum(a[0:n])
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
while i <= n:
	mid = (i + n) // 2
	if check(mid, s, 1):
		if i == mid:
			break
		i = mid
	else:
		n = mid - 1
if check(n, s, 1):
	print(n, check(n, s, 0))
else:
	print(i, check(i, s, 0))


(n, S) = map(int, input().split())
arr = list(map(int, input().split()))
(l, r) = (0, n)
ac = 0
while l < r:
	k = l + r + 1 >> 1
	at = [x + (i + 1) * k for (i, x) in enumerate(arr)]
	at.sort()
	cost = sum(at[:k])
	if cost <= S:
		l = k
		ac = cost
	else:
		r = k - 1
print(l, ac)


(n, S) = map(int, input().split())
a = list(map(int, input().split()))
start = 0
end = n
T = 0
Tc = 0
Kc = 0
found = False
while start <= end and (not found):
	k = (start + end) // 2
	tc = a[:]
	for i in range(n):
		tc[i] = tc[i] + (i + 1) * k
	tc.sort()
	T = 0
	for i in range(k):
		T += tc[i]
	if T > S:
		end = k - 1
	elif T < S:
		start = k + 1
		Tc = T
		Kc = k
	else:
		found = True
		Tc = T
		Kc = k
print(Kc, Tc)


def get(k, li):
	a = [0] * len(li)
	for i in range(len(li)):
		a[i] = li[i] + (i + 1) * k
	a.sort()
	summ = 0
	for i in range(k):
		summ += a[i]
	return summ

def b_search(n, li, k):
	l = 0
	h = n + 1
	while h - l > 1:
		m = (l + h) // 2
		if get(m, li) <= k:
			l = m
		else:
			h = m
	print(l, get(l, li))
(n, m) = map(int, input().split())
li = list(map(int, input().split()))
b_search(n, li, m)


def cost_total(num_souvenir, budget, costs_base, k):
	costs_total = [costs_base[i] + (k + 1) * (i + 1) for i in range(num_souvenir)]
	costs_total.sort()
	suma = 0
	for i in range(k + 1):
		suma = costs_total[i] + suma
	return suma

def busqueda_binaria(num_souvenir, budget, costs_base):
	minimo = 0
	maximo = num_souvenir - 1
	ultimo_valido = -1
	ultima_suma = -1
	flag = False
	while minimo <= maximo:
		medio = int((minimo + maximo) / 2)
		suma = cost_total(num_souvenir, budget, costs_base, medio)
		if suma == budget:
			flag = True
			print(str(medio + 1) + ' ' + str(suma))
			break
		elif suma < budget:
			ultima_suma = suma
			ultimo_valido = medio
			minimo = medio + 1
		else:
			maximo = medio - 1
	if flag == False:
		if ultima_suma == -1:
			print('0 0')
		else:
			print(str(ultimo_valido + 1) + ' ' + str(ultima_suma))

def main():
	(num_souvenir, budget) = map(int, input().split(' '))
	costs_base = list(map(int, input().split(' ')))
	busqueda_binaria(num_souvenir, budget, costs_base)
main()


import sys
(n, s) = list(map(int, input().split()))
price = list(map(int, input().split()))
lo = 0
hi = n
ans = 0
cst = sys.maxsize
while lo <= hi:
	total = s
	k = (lo + hi) // 2
	newPrice = []
	for i in range(n):
		newPrice.append(price[i] + k * (i + 1))
	newPrice.sort()
	cnt = 0
	cost = 0
	for i in range(k):
		total -= newPrice[i]
		if total < 0:
			break
		cost += newPrice[i]
		cnt += 1
	if cnt == k:
		lo = k + 1
		if cnt > ans:
			ans = cnt
			cst = cost
		if cnt == ans:
			cst = min(cst, cost)
	else:
		if cnt > ans:
			ans = cnt
			cst = cost
		if cnt == ans:
			cst = min(cst, cost)
		hi = k - 1
print(ans, cst)


from random import *
from bisect import *

def solve(k, l, s):
	global temp
	global cost
	for i in range(n):
		temp[i] = l[i] + k * (i + 1)
	temp.sort()
	cost = 0
	for i in range(k):
		cost += temp[i]
	return cost <= s
(n, s) = map(int, input().split())
cost = 0
temp = [0 for i in range(n)]
l = [*map(int, input().split())]
low = 0
high = n
while low < high:
	mid = (low + high + 1) // 2
	if solve(mid, l, s):
		low = mid
	else:
		high = mid - 1
solve(low, l, s)
print(low, cost)


from sys import stdin

def check(n, s, a):
	a.sort(key=lambda x: x[1] * n + x[0])
	r = 0
	for i in a[:n]:
		r += i[0] + i[1] * n
	return r

def main():
	(n, s) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	for i in range(n):
		a[i] = [a[i], i + 1]
	l = 0
	res = 0
	r = n + 1
	while r - l > 1:
		m = (l + r) // 2
		b = a[:]
		res_new = check(m, s, b)
		if res_new <= s:
			l = m
			res = res_new
		else:
			r = m
	print(l, res)
main()


def check(k):
	return sum(sorted([a[i] + (i + 1) * k for i in range(n)])[:k])

def binary(p, q):
	if p >= q:
		return p if check(p) <= s else p - 1
	mid = (p + q) // 2
	if check(mid) <= s:
		return binary(mid + 1, q)
	else:
		return binary(p, mid - 1)
(n, s) = map(int, input().split())
a = [*map(int, input().split())]
ans = binary(0, n)
print(ans, check(ans))


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	nonlocal tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())

def min_cost(a, k):
	if k > len(a):
		return False
	new_a = [a[i] + (i + 1) * k for i in range(len(a))]
	new_a = sorted(new_a)
	return sum(new_a[:k])
n = nextInt()
S = nextInt()
a = [nextInt() for _ in range(n)]
low = 0
high = n + 1
while low + 1 < high:
	mid = (low + high) // 2
	if min_cost(a, mid) <= S:
		low = mid
	else:
		high = mid
print(low, min_cost(a, low))


from sys import stdin
from collections import defaultdict
import sys

def check_cost(num, cost, s):
	copy = cost[:]
	for i in range(len(copy)):
		copy[i] = copy[i] + (i + 1) * num
	copy.sort()
	if sum(copy[:num]) <= s:
		return True
	else:
		return False
sys.setrecursionlimit(15000)
(n, s) = list(map(int, stdin.readline().split()))
cost = list(map(int, stdin.readline().split()))
start = 1
end = n
while start <= end:
	if start == end:
		if check_cost(start, cost, s):
			break
		else:
			start -= 1
			break
	mid = (start + end) // 2
	if check_cost(mid, cost, s):
		start = mid + 1
		continue
	else:
		end = mid - 1
if check_cost(start, cost, s):
	pass
else:
	start -= 1
for i in range(len(cost)):
	cost[i] = cost[i] + (i + 1) * start
cost.sort()
print(start, sum(cost[:start]))


def total_cost(k):
	cost = [a[i] + (i + 1) * k for i in range(len(a))]
	cost.sort()
	return sum(cost[:k])
(n, S) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
(l, h) = (0, n + 1)
while l < h - 1:
	mid = (l + h) // 2
	if total_cost(mid) <= S:
		l = mid
	else:
		h = mid
print('{0} {1}'.format(l, total_cost(l)))


from sys import stdin, stderr

def readInts():
	return map(int, stdin.readline().strip().split())

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def best_souvenirs(n, s, ns):

	def attemptf(k):
		ns2 = []
		for (i, v) in enumerate(ns):
			ns2.append(ns[i] + (i + 1) * k)
		ns2.sort()
		buy = sum(ns2[:k])
		if buy > s:
			return None
		return buy

	def binary_search(lo, hi, f):
		best_v = 0
		best_mid = 0
		while lo + 1 < hi:
			mid = (lo + hi) // 2
			v = f(mid)
			if v:
				lo = mid
				best_v = v
				best_mid = mid
			else:
				hi = mid
		return (best_mid, best_v)
	return binary_search(0, len(ns) + 1, attemptf)

def run():
	(n, s) = readInts()
	ns = list(readInts())
	print(' '.join(map(str, best_souvenirs(n, s, ns))))
run()


def check(x, A, s):
	n = len(A)
	B = [0 for i in range(n)]
	for i in range(n):
		B[i] = A[i] + (i + 1) * x
	B.sort()
	c = 0
	for i in range(x):
		c += B[i]
	return c
(n, s) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = n + 1
ans = 0
while l < r - 1:
	mid = (l + r) // 2
	if check(mid, A, s) <= s:
		l = mid
		ans = mid
	else:
		r = mid
print(ans, check(ans, A, s))


vals = input().split()
n = int(vals[0])
S = int(vals[1])
a = [int(v) for v in input().split()]
left = 0
right = n - 1
answer1 = 0
answer2 = 0
while left <= right:
	mid = (left + right) // 2
	c = [x + (index + 1) * (mid + 1) for (index, x) in enumerate(a)]
	c.sort()
	min_sum = 0
	for i in range(mid + 1):
		min_sum += c[i]
	if min_sum <= S:
		answer1 = mid + 1
		answer2 = min_sum
		left = mid + 1
	else:
		right = mid - 1
print(answer1, answer2)


def cheapestPrice(A, k):
	prices = []
	for (i, a) in enumerate(A):
		prices.append(a + (i + 1) * k)
	prices.sort()
	return sum(prices[:k])

def ok(A, S, k):
	return cheapestPrice(A, k) <= S
(n, S) = map(int, input().split())
A = [int(a) for a in input().split()]
k = -1
skip = n
while skip >= 1:
	while k + skip <= n and ok(A, S, k + skip):
		k += skip
	skip //= 2
print(k, cheapestPrice(A, k))