You are given a permutation $p_1, p_2, \ldots, p_n$ of integers from $1$ to $n$ and an integer $k$, such that $1 \leq k \leq n$. A permutation means that every number from $1$ to $n$ is contained in $p$ exactly once.

Let's consider all partitions of this permutation into $k$ disjoint segments. Formally, a partition is a set of segments $\{[l_1, r_1], [l_2, r_2], \ldots, [l_k, r_k]\}$, such that:

  $1 \leq l_i \leq r_i \leq n$ for all $1 \leq i \leq k$;  For all $1 \leq j \leq n$ there exists exactly one segment $[l_i, r_i]$, such that $l_i \leq j \leq r_i$. 

Two partitions are different if there exists a segment that lies in one partition but not the other.

Let's calculate the partition value, defined as $\sum\limits_{i=1}^{k} {\max\limits_{l_i \leq j \leq r_i} {p_j}}$, for all possible partitions of the permutation into $k$ disjoint segments. Find the maximum possible partition value over all such partitions, and the number of partitions with this value. As the second value can be very large, you should find its remainder when divided by $998\,244\,353$.


-----Input-----

The first line contains two integers, $n$ and $k$ ($1 \leq k \leq n \leq 200\,000$) — the size of the given permutation and the number of segments in a partition.

The second line contains $n$ different integers $p_1, p_2, \ldots, p_n$ ($1 \leq p_i \leq n$) — the given permutation.


-----Output-----

Print two integers — the maximum possible partition value over all partitions of the permutation into $k$ disjoint segments and the number of such partitions for which the partition value is equal to the maximum possible value, modulo $998\,244\,353$.

Please note that you should only find the second value modulo $998\,244\,353$.


-----Examples-----
Input
3 2
2 1 3

Output
5 2

Input
5 5
2 1 5 3 4

Output
15 1

Input
7 3
2 7 3 1 5 4 6

Output
18 6



-----Note-----

In the first test, for $k = 2$, there exists only two valid partitions: $\{[1, 1], [2, 3]\}$ and $\{[1, 2], [3, 3]\}$. For each partition, the partition value is equal to $2 + 3 = 5$. So, the maximum possible value is $5$ and the number of partitions is $2$.

In the third test, for $k = 3$, the partitions with the maximum possible partition value are $\{[1, 2], [3, 5], [6, 7]\}$, $\{[1, 3], [4, 5], [6, 7]\}$, $\{[1, 4], [5, 5], [6, 7]\}$, $\{[1, 2], [3, 6], [7, 7]\}$, $\{[1, 3], [4, 6], [7, 7]\}$, $\{[1, 4], [5, 6], [7, 7]\}$. For all of them, the partition value is equal to $7 + 5 + 6 = 18$. 

The partition $\{[1, 2], [3, 4], [5, 7]\}$, however, has the partition value $7 + 3 + 6 = 16$. This is not the maximum possible value, so we don't count it.

Difficulty: EASY
Tags: Combinatorics

Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
(n, k) = [int(el) for el in input().split()]
per = [int(el) for el in input().split()]
sp = sorted(per, reverse=True)
sp.append(0)
mod = 998244353
result = 1
prev = 0
for (i, p) in enumerate(per, 1):
	if p > sp[k]:
		if not prev:
			prev = i
		else:
			result *= i - prev
			result %= mod
			prev = i
print(sum(sp[:k]), result)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def modInt(mod):

	class ModInt:

		def __init__(self, value):
			self.value = value % mod

		def __int__(self):
			return self.value

		def __eq__(self, other):
			return self.value == other.value

		def __hash__(self):
			return hash(self.value)

		def __add__(self, other):
			return ModInt(self.value + int(other))

		def __sub__(self, other):
			return ModInt(self.value - int(other))

		def __mul__(self, other):
			return ModInt(self.value * int(other))

		def __floordiv__(self, other):
			return ModInt(self.value // int(other))

		def __truediv__(self, other):
			return ModInt(self.value * pow(int(other), mod - 2, mod))
	return ModInt

def main():
	(n, k) = map(int, input().split())
	pp = [int(a) for a in input().split()]
	mx = (2 * n + 1 - k) * k // 2
	ModInt = modInt(998244353)
	count = ModInt(1)
	res = ModInt(1)
	started = False
	for p in pp:
		if p > n - k:
			if started:
				res *= count
			count = ModInt(1)
			started = True
		else:
			count += 1
	print(mx, int(res))
main()


mod = 998244353
(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
b = [1] * k
k1 = 0
s = 0
p = 1
for i in range(0, n):
	if a[i] > n - k:
		if k1 == 0:
			x = i
			k1 = 1
			s += a[i]
		else:
			s += a[i]
			p = p * (i % mod - x % mod) % mod % mod
			x = i
print(s, p % mod)


(n, k) = map(int, input().split())
l = [0] * n
a = list(map(int, input().split()))
for i in range(n):
	l[n - a[i]] = i
ll = []
j = 0
for i in range(k):
	ll.append(l[i])
	j += n - i
ll.sort()
ans = 1
for i in range(k - 1):
	ans = ans * (ll[i + 1] - ll[i]) % 998244353
print(j, ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ls = []
for i in range(n):
	ls.append([p[i], i])
ls = sorted(ls)[::-1]
res = []
sm = 0
for i in range(k):
	sm += ls[i][0]
	res.append(ls[i][1])
pro = 1
res.sort()
for i in range(1, k):
	pro *= res[i] - res[i - 1]
print(sm, pro % 998244353)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l, k):
	n = len(l)
	mod = 998244353
	L = []
	if k == 1 or n == 1:
		return [max(l), 1]
	else:
		pre = [0] * n
		pre[0] = l[0]
		last = 0
		ll = []
		maxx = 0
		for i in range(n):
			if l[i] >= n - k + 1:
				maxx += l[i]
				ll.append(i)
		cc = 1
		for i in range(1, k):
			cc *= ll[i] - ll[i - 1]
			cc %= mod
		return [maxx, cc]
(N, K) = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l, K)
print(*ans)


import itertools
import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
ps = list(map(int, input().split()))
ksps = sorted(ps)[-k:]
ans1 = sum(ksps)
ips = [0] * (n + 1)
for (kk, v) in enumerate(ps):
	ips[v] = kk
js = sorted([ips[k] for k in ksps])
delta_js = [js[i] - js[i - 1] for i in range(1, len(js))]
ans2 = 1
for i in delta_js:
	ans2 = ans2 * i % 998244353
print(ans1, ans2)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans
from math import *
for _ in range(1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	start = n - k + 1
	end = n
	(sumi, ans) = (0, 1)
	sumi = (2 * n - k + 1) * k // 2
	ind = []
	for i in range(n):
		if start <= a[i] <= end:
			ind.append(i)
	mod = 998244353
	for i in range(1, len(ind)):
		ans = ans * (ind[i] - ind[i - 1]) % mod
	print(sumi, ans)


R = lambda : map(int, input().split())
(n, k) = R()
i = j = r = 0
for x in R():
	if x > n - k:
		r = r * (j - i) % 998244353 or 1
		i = j
	j += 1
print(n * k - k * (k - 1) // 2, r)


def getPartitions(N, K):
	n1 = N * (N + 1) / 2
	n2 = K * (K + 1) / 2
	return n1 - n2
(N, K) = map(int, input().strip().split())
P = list(map(int, input().strip().split()))
Prod = 1
mod = 998244353
Partitions = int(getPartitions(N, N - K))
L = N - K + 1
H = N
prev = -1
for i in range(0, len(P)):
	if P[i] <= N and P[i] >= L:
		if prev != -1:
			k1 = i - prev
			Prod = Prod % mod * (k1 % mod) % mod
		prev = i
print(Partitions, Prod)


(n, k) = map(int, input().split())
numbers = list(map(int, input().split()))
m = sum(numbers[:k])
s = list(enumerate(numbers))
s.sort(key=lambda l: l[1], reverse=True)
r = s[:k]
r.sort(key=lambda el: el[0])
result_count = 1
t = r[0][0]
for (index, value) in r:
	result_count *= index + 1 - t
	t = index + 1
result_sum = sum((el[1] for el in s[:k]))
print(f'{result_sum} {result_count % 998244353}')


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
sum1 = 0
for i in range(k):
	sum1 += n - i
dict1 = {}
for i in range(len(lst)):
	dict1[lst[i]] = i
ways = 0
lst2 = []
for i in dict1:
	if i >= n - k + 1:
		lst2.append(dict1[i])
lst2.sort()
if len(lst2) == 1:
	ways = 1
else:
	ways = 1
	for i in range(len(lst2) - 1):
		ways = ways * (lst2[i + 1] - lst2[i])
print(sum1, ways % 998244353)


(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
mod = 998244353
res = 1
count = 0
flag = 0
for x in l1:
	if x >= n - k + 1:
		if flag == 1:
			res = res * (count + 1) % mod
			count = 0
		else:
			flag = 1
			count = 0
	else:
		count += 1
x = n - k
print(n * (n + 1) // 2 - x * (x + 1) // 2, res)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
MOD = 998244353
(n, k) = mi()
p = li()
if n == k:
	print(n * (n + 1) // 2, 1)
	exit()
max_ = n * k - (k - 1) * k // 2
s = set()
ans = 1
for i in range(n - k, n):
	s.add(i + 1)
t = []
for i in range(n):
	if p[i] in s:
		t.append(i)
for i in range(k - 1):
	ans *= t[i + 1] - t[i]
print(max_, ans % MOD)


(n, k) = map(int, input().split())
i = r = 0
for (j, a) in enumerate(map(int, input().split())):
	if a > n - k:
		r = r * (j - i) % 998244353 or 1
		i = j
print(int((2 * n - k + 1) * k / 2), r % 998244353)


liStr = input().split()
n = int(liStr[0])
k = int(liStr[1])
liStr = input().split()
arr = []
for i in liStr:
	arr.append(int(i))
ok = set()
num = n
s = 0
for i in range(1, k + 1):
	ok.add(num)
	s += num
	num -= 1
if k == 1:
	print(s, 1)
elif k == n:
	print(s, 1)
last = n
for i in range(0, n):
	if arr[i] in ok:
		last = i
nset = 1
f = 0
a = 0
for i in range(0, n):
	if f == 0 and arr[i] in ok:
		f = 1
		a = i
		continue
	if f == 1 and arr[i] in ok:
		diff = i - a
		a = i
		nset = nset * diff % 998244353
if k != 1 and k != n:
	print(s, nset % 998244353)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
h = n - k + 1
c = 0
d = 1
s = 0
for j in range(len(b)):
	if b[j] >= h and c == 0:
		p = j
		c = 1
		s += b[j]
	elif b[j] >= h and c == 1:
		d = d * (j - p) % 998244353
		p = j
		s += b[j]
print(s, d % 998244353)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
MOD = 998244353
poses = []
res = 0
for i in range(len(l)):
	if l[i] > n - k:
		poses.append(i)
		res += l[i]
muls = 1
for i in range(len(poses) - 1):
	muls *= poses[i + 1] - poses[i]
	muls %= MOD
print(res, muls)


import sys
import heapq
(n, k) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
topk = []
heapq.heapify(topk)
flag = False
for i in range(n):
	e = a[i]
	heapq.heappush(topk, (e, i))
	if len(topk) > k:
		heapq.heappop(topk)
topk.sort(key=lambda x: x[1])
total = 0
result = 1
previ = None
for (e, i) in topk:
	total += e
	if previ != None:
		result = result * (i - previ) % 998244353
	previ = i
print(total, result)


from sys import stdin, stdout
from collections import deque

def main():
	mod = 998244353
	(n, k) = map(int, stdin.readline().split())
	arr = [int(k) for k in stdin.readline().split()]
	total = 0
	ans = 1
	index = []
	for i in range(n):
		if arr[i] >= n - k + 1:
			index.append(i)
			total += arr[i]
	i = 0
	while i + 1 < len(index):
		ans = ans * (index[i + 1] - index[i])
		ans = ans % mod
		i += 1
	print(total, ans)
main()


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
min_val = N + 1 - K
ans1 = (min_val + N) * K // 2
idx = 0
while P[idx] < min_val:
	idx += 1
ans2 = 1
cnt = 1
for p in P[idx + 1:]:
	if p >= min_val:
		ans2 = ans2 * cnt % 998244353
		cnt = 1
	else:
		cnt += 1
print(ans1, ans2)


import heapq
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = p.copy()
heapq.heapify(q)
extractedP = heapq.nlargest(k, enumerate(p), key=lambda x: x[1])
po = 1
sum = 0
indexes = []
for i in range(len(extractedP)):
	indexes.append(extractedP[i][0])
	sum = sum + extractedP[i][1]
sortedInd = sorted(indexes)
for i in range(1, len(sortedInd)):
	po = po * (sortedInd[i] - sortedInd[i - 1])
print(sum, po % 998244353)


from collections import deque
(n, k) = map(int, input().split())
arr = deque(map(int, input().split()))
mx = (n + n - k + 1) * k // 2
res = 1
while len(arr) and arr[0] <= n - k:
	arr.popleft()
while len(arr) and arr[-1] <= n - k:
	arr.pop()
bf = 0
for i in list(arr)[1:]:
	bf += 1
	if not i <= n - k:
		res *= bf
		res %= 998244353
		bf = 0
if bf > 0:
	res *= bf
	res %= 998244353
print(mx, res)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
mod = 998244353
maxsum = 0
for i in range(k):
	maxsum += i + (n - k + 1)
lastind = None
ans = 1
for i in range(n):
	if p[i] >= n - k + 1:
		if lastind == None:
			lastind = i
		else:
			ans *= i - lastind
			ans %= mod
			lastind = i
print(maxsum, ans)


(n, k) = map(int, input().split())
a = [*map(int, input().split())]
l = r = ans = 0
for i in a:
	if i > n - k:
		ans = ans * (r - l) % 998244353 or 1
		l = r
	r += 1
print(n * k - k * (k - 1) // 2, ans)


(a, b) = map(int, input().split())
k = []
s = 1
for (i, j) in zip(range(1, a + 1), map(int, input().split())):
	if a - b < j <= a:
		k += [i]
for i in range(1, b):
	s *= k[i] - k[i - 1]
	s %= 998244353
print(a * (a + 1) // 2 - (a - b) * (a - b + 1) // 2, s)


from math import *
from copy import *
from sys import *
LIST = []
for i in range(200001):
	LIST.append(0)
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
SUM = 0
for i in range(k):
	SUM += n - i
	LIST[n - i] = 1
ind = []
prod = 1
for i in range(len(l)):
	if LIST[l[i]] == 1:
		ind.append(i)
for i in range(len(ind) - 1):
	prod *= (ind[i + 1] - ind[i]) % 998244353
print(SUM, prod % 998244353)


for i in range(1):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	d = []
	for i in range(n):
		if li[i] > n - k:
			d.append(i)
	ans = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
	ans1 = 1
	mod = 998244353
	for i in range(k - 1):
		ans1 *= d[i + 1] - d[i]
		ans1 %= mod
	print(ans, ans1)


import sys
import copy
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def pr_list(a):
	print(*a, sep=' ')

def main():
	[n, k] = inlt()
	a = inlt()
	mod = 998244353
	thres = n - k + 1
	found = 0
	curr = 0
	first = 0
	second = 1
	for i in range(0, n):
		if a[i] >= thres:
			first += a[i]
			if found != 0:
				second = second * (i - curr)
				second = second % mod
			else:
				found = 1
			curr = i
	pr_list([first, second])
	return
main()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
l = []
a1 = 0
a2 = 1
for i in range(n):
	if p[i] > n - k:
		a1 += p[i]
		l.append(i)
if k > 1:
	for i in range(1, k):
		a2 = a2 * (l[i] - l[i - 1])
print(a1, a2 % 998244353)


def permutation_partitions(size, num_partitions, permutation):
	lowest_number = size - num_partitions
	total = 0
	num_max_partitions = 1
	current_space = None
	for number in permutation:
		if number <= lowest_number and current_space is None:
			continue
		if current_space is None:
			current_space = 1
		elif number > lowest_number:
			num_max_partitions = num_max_partitions * current_space
			current_space = 1
		else:
			current_space += 1
	total = (2 * size - num_partitions + 1) * num_partitions / 2
	return (int(total), num_max_partitions)
(n, k) = map(int, input().split())
s = input().split()
s = [int(i) for i in s]
(max_sum, num_max_partitions) = permutation_partitions(n, k, s)
print(f'{max_sum} {num_max_partitions % 998244353}')


t = 998244353
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pos = []
ans = 0
for i in range(n):
	if a[i] <= n and a[i] >= n - k + 1:
		pos.append(i)
		ans += a[i]
poss = 1
for i in range(1, k):
	poss = poss % t * ((pos[i] - pos[i - 1]) % t) % t
print(ans, poss % t)


(n, k) = map(int, input().split())
index = [0] * (n + 1)
p = [int(i) for i in input().split()]
for i in range(len(p)):
	index[p[i]] = i + 1
p.sort()
file = []
summa = 0
for i in range(n - k, n):
	summa += p[i]
	file.append(index[p[i]])
file.sort()
mul = 1
for i in range(1, len(file)):
	mul *= file[i] - file[i - 1]
	mul %= 998244353
print(summa, mul)


(n, k) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
st = set()
mod = 998244353
for i in range(k):
	st.add(n - i)
ind = []
for i in range(len(p)):
	if p[i] in st:
		ind.append(i)
ans = 1
for i in range(1, k):
	ans = ans * (ind[i] - ind[i - 1]) % mod
print(k * n - k * (k - 1) // 2, ans)


from sys import stdin, stdout
arr1 = [int(x) for x in stdin.readline().split()]
arr2 = [int(x) for x in stdin.readline().split()]
k = arr1[1]
n = arr1[0]
ans1 = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2
dicti = {}
top = [0] * k
for i in range(k):
	dicti[n - i] = 0
for i in range(n):
	if arr2[i] in dicti:
		dicti[arr2[i]] = i
count = 0
for item in dicti.values():
	top[count] = item
	count = count + 1
top.sort()
ans2 = 1
for i in range(len(top) - 1):
	ans2 = ans2 * (top[i + 1] - top[i])
print(int(ans1), ans2 % 998244353)


import sys
from math import *
from collections import defaultdict
from queue import deque
from heapq import heappush, heappop
M = 998244353
lines = [line.strip() for line in sys.stdin.readlines()]
(n, k) = list(map(int, lines[0].split()))
ps = list(map(int, lines[1].split()))
pos = [-1 for i in range(n)]
for i in range(n):
	pos[ps[i] - 1] = i
xs = []
ret1 = 0
for i in range(n - 1, n - k - 1, -1):
	ret1 += i + 1
	xs += [pos[i]]
xs.sort()
ret2 = 1
for i in range(len(xs) - 1):
	ret2 = ret2 * (xs[i + 1] - xs[i]) % M
print('%d %d' % (ret1, ret2))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
mi = n - k
ma = n
ans = []
for i in range(n):
	if l[i] > mi:
		ans.append(i + 1)
a = 1
for i in range(1, k):
	a = a * (ans[i] - ans[i - 1]) % 998244353
print(int(k / 2 * (mi + 1 + ma)), a)


import sys
import math
input = sys.stdin.readline
(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
for i in range(n):
	l[i] = (l[i], i)
z = sorted(l, key=lambda x: (-x[0], x[1]))
ans = 0
arr = []
m = 998244353
for i in range(k):
	ans += z[i][0]
	arr.append(z[i][1])
z = 1
ans = ans
arr.sort()
for i in range(len(arr) - 1):
	if arr[i] != arr[i + 1] - 1:
		d = arr[i + 1] - arr[i]
		z = z * (d % m) % m
z = z % m
print(ans, z)


import sys, math, itertools, collections, copy
input = sys.stdin.readline
MOD = 998244353
(N, K) = map(int, input().split())
a = [int(x) for x in input().split()]
helper = copy.deepcopy(a)
helper.sort(reverse=True)
Hashset = set()
for i in range(K):
	Hashset.add(helper[i])
indexes = []
(ans, s) = (1, 0)
for i in range(N):
	if a[i] in Hashset:
		indexes.append(i)
		s += a[i]
for i in range(K - 1):
	ans *= (indexes[i + 1] - indexes[i]) % MOD
	ans %= MOD
print(s, ans)


(n, k) = map(int, input().split())
mylist = list(map(int, input().split()))
ans1 = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2
lowest = n - k + 1
list1 = list()
i = 0
count = 0
previous = -1
ans2 = 1
while i < len(mylist):
	if mylist[i] >= lowest:
		if previous != -1:
			ans2 = ans2 * (i - previous) % 998244353
		previous = i
	i += 1
print(int(ans1), ans2)


(n, k) = map(int, input().split())
u = list(map(int, input().split()))
a1 = []
for i in range(n):
	if u[i] > n - k:
		a1.append(i)
a1.append(n)
a = a1[:]
for i in range(1, len(a)):
	a[i] -= a1[i - 1] + 1
q = 998244353
ans = 1
for i in range(1, len(a) - 1):
	ans *= a[i] + 1
	ans %= q
print(n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2, ans % q)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [[2, 2]] * n
for i in range(n):
	b[i] = [a[i], i]
b.sort(reverse=True)
s = 1
c = [0] * k
o = 0
for i in range(k):
	c[i] = b[i][1]
	o += b[i][0]
c.sort()
for i in range(k - 1):
	s *= c[i + 1] - c[i]
	s %= 998244353
print(o, s)


import sys, heapq
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())
	al = list(map(int, input().split()))
	used = [False] * n
	s = 0
	for i in range(n):
		if al[i] >= n - k + 1:
			used[i] = True
			s += al[i]
	for i in range(n):
		if used[i] == True:
			break
		used[i] = True
	for i in range(n):
		if used[n - i - 1] == True:
			break
		used[n - i - 1] = True
	ans = 1
	cnt = 0
	for i in used:
		if i == False:
			cnt += 1
		else:
			ans *= cnt + 1
			ans %= 998244353
			cnt = 0
	print(s, ans)
main()


(n, k) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
positions = []
for i in range(n):
	if L[i] >= n - k + 1:
		positions.append(i)
distances = []
for i in range(k - 1):
	distances.append(positions[i + 1] - positions[i])
ans1 = 0
for i in range(k):
	ans1 += n - i
ans2 = 1
for i in range(k - 1):
	ans2 = ans2 * distances[i] % 998244353
print(ans1, ans2)


m = 998244353
(n, k) = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = sum((n - i for i in range(k)))
ans1 = 1
cnt = 0
val_cnt = 0
for val in seq:
	if val > n - k:
		f = cnt + 1
		ans1 *= f
		if ans1 >= m:
			ans1 = ans1 % m
		cnt = 0
		val_cnt += 1
		continue
	if val_cnt > 0 and val_cnt < k:
		cnt += 1
f = cnt + 1
ans1 *= f
if ans1 >= m:
	ans1 = ans1 % m
print(ans, ans1)


mod = 998244353
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = {}
for i in range(n):
	l[a[i]] = i
g = []
for i in range(n - k + 1, n + 1):
	g.append(l[i])
g.sort()
ans = 1
for i in range(1, len(g)):
	ans *= g[i] - g[i - 1]
	ans %= mod
print(sum(sorted(a)[n - k:]), ans)


R = lambda : map(int, input().split())
(n, k) = R()
(a, b) = zip(*sorted(zip(R(), range(n)))[-k:])
b = sorted(b)
r = 1
for (i, j) in zip(b, b[1:]):
	r = r * (j - i) % 998244353
print(sum(a), r)


(n, k) = map(int, input().split())
(*p,) = map(int, input().split())
ind = []
dic = {e: i for (i, e) in enumerate(p)}
for e in range(n - k + 1, n + 1):
	ind.append(dic[e])
ind.sort()
ans = 1
for i in range(len(ind) - 1):
	ans *= ind[i + 1] - ind[i]
	ans %= 998244353
print((2 * n - k + 1) * k // 2, end=' ')
print(ans)


md = 998244353
a = []
(n, m) = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * (n - m) + [1] * m
k = m * (2 * n - m + 1) // 2
an = 1
for i in range(n):
	if l[p[i] - 1]:
		a.append(i)
		if len(a) > 1:
			an = an * (i - a[-2]) % md
print(k, an)


mod = 998244353
(n, k) = input().split()
n = int(n)
k = int(k)
arr = list(map(int, input().split()))
arr1 = [(arr[i], i) for i in range(n)]
arr1.sort(reverse=True)
ind = []
ans = 0
for i in range(k):
	ind.append(arr1[i][1])
	ans += arr1[i][0]
ind.sort()
ans1 = 1
for i in range(k - 1):
	ans1 = ans1 * (ind[i + 1] - ind[i]) % mod
print(ans, ans1)


(n, k) = map(int, input().split())
a = [0] * 200001
b = list(map(int, input().split()))
for i in range(len(b)):
	a[b[i]] = i
c = []
sum = 0
for i in range(n, n - k, -1):
	sum += i
	c.append(a[i])
c.sort()
ans = 1
for i in range(len(c) - 1):
	ans *= c[i + 1] - c[i]
	ans %= 998244353
print(sum, ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
(prev, sum, ways) = (-1, 0, 1)
MOD = 998244353
for i in range(n):
	if p[i] >= n - k + 1:
		if prev != -1:
			ways = ways * (i - prev) % MOD
		prev = i
		sum += p[i]
print(sum, ways)


from sys import exit

def i():
	return input()

def ii():
	return int(input())

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

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

def print_array(a):
	print(' '.join(map(str, a)))
(n, k) = iis()
p = liis()
a = n - k + 1
b = n
ans1 = (b - a + 1) * (b + a) // 2
positions = []
for (idx, i) in enumerate(p):
	if i >= a:
		positions.append(idx)
ans2 = 1
for i in range(1, len(positions)):
	ans2 *= positions[i] - positions[i - 1]
print(ans1, ans2 % 998244353)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = sorted(p, reverse=True)
(s, m) = (0, -1)
x = 0
j = 0
for i in range(k):
	s += q[i]
	x = q[i]
for i in range(n):
	if p[i] >= x:
		if m == -1:
			j = i
			m = 1
		else:
			m *= i - j
			j = i
print(s, m % 998244353)


import math
specs = input().split()
n = int(specs[0])
k = int(specs[1])
perm = []
perm_sorted = []
data = input().split()
for i in data:
	perm.append(int(i))
	perm_sorted.append(int(i))
perm_sorted.sort()
maxx = 0
for i in range(k):
	maxx += perm_sorted[n - 1 - i]
cutoff = perm_sorted[n - k]
poss = 1
start = 0
count = 0
for i in range(len(perm)):
	if perm[i] < cutoff:
		count += 1
	elif start == 0:
		start = 1
		count = 0
	else:
		poss *= count + 1
		poss = poss % 998244353
		count = 0
print(maxx, poss)


from functools import lru_cache
from collections import *
(n, k) = map(int, input().split())
P = list(map(int, input().split()))
pv = k * n - k * (k - 1) // 2
res = 1
prev = -1
for (i, x) in enumerate(P):
	if x >= n - k + 1:
		if prev != -1:
			res *= i - prev
			prev = i
		else:
			prev = i
print(pv, res % 998244353)


from sys import stdin
input = stdin.readline
import math
mod = 998244353
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
b = sorted(arr)
b.reverse()
ans1 = sum(b[0:k])
q = b[k - 1]
vec = []
for i in range(n):
	if arr[i] >= q:
		vec.append(i)
ans2 = 1
for i in range(len(vec) - 1):
	ans2 = ans2 * (vec[i + 1] - vec[i])
	ans2 %= mod
print(ans1, ans2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ind = []
for i in range(n):
	if n - k + 1 <= a[i] <= n:
		ind.append(i)
s = 0
for i in ind:
	s += a[i]
count = 1
p = 998244353
for i in range(1, len(ind)):
	count = count % p * (ind[i] - ind[i - 1]) % p % p
print(s, count)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ind = []
new = [(l[i], i) for i in range(n)]
new.sort(reverse=True)
ans = 1
s = 0
for i in range(k):
	s += new[i][0]
	ind.append(new[i][1])
ind.sort()
for i in range(1, k):
	ans *= ind[i] - ind[i - 1]
	ans %= 998244353
print(s, ans % 998244353)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sum = 0
ways = 1
faltu = 0
for i in range(0, n):
	if a[i] <= n and a[i] >= n - k + 1:
		sum = sum + a[i]
		if faltu == 0:
			faltu = i + 1
		else:
			ways = ways * (i + 1 - faltu)
			faltu = i + 1
print(sum, end=' ')
print(ways % 998244353)


mod = 998244353

def pro(arr, n, k):
	l = n - k + 1
	r = n
	lst = []
	sumi = 0
	for i in range(n):
		if l <= arr[i] <= r:
			lst.append(i)
			sumi += arr[i]
	ans = 1
	for i in range(1, len(lst)):
		ans = ans * (lst[i] - lst[i - 1]) % mod
	print(sumi, ans % mod)
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
pro(arr, n, k)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
for i in range(n, n - k, -1):
	s = s + i
d = [-1] * (n + 1)
for i in range(n):
	d[l[i]] = i + 1
p = 1
x = 998244353
ll = []
for i in range(n, n - k, -1):
	ll.append(d[i])
ll.sort()
for i in range(len(ll) - 1):
	g = ll[i + 1] - ll[i]
	p = p * g % x
print(s, p)


import collections

def solve(n, k, arr):
	(ans1, ways) = (0, 1)
	numbersIWant = []
	for i in range(n):
		if arr[i] >= n - k + 1:
			ans1 += arr[i]
			numbersIWant.append(i)
	for i in range(1, len(numbersIWant)):
		ways *= numbersIWant[i] - numbersIWant[i - 1]
	return ' '.join(map(str, [ans1, ways % 998244353]))
[n, k] = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))
print(solve(n, k, arr))


(n, k) = map(int, input().split())
pp = [int(i) for i in input().split()]
kk = set([int(i) for i in range(n - k + 1, n + 1)])
(prev, pro) = (0, 1)
for i in range(1, n + 1):
	if pp[i - 1] in kk:
		if prev == 0:
			prev = i
			continue
		pro *= i - prev
		pro %= 998244353
		prev = i
print(sum(kk), pro)


line = input().split()
(n, k) = (int(line[0]), int(line[1]))
p = input().split()
p = [int(x) for x in p]
m = 998244353
idx = []
ss = set([i for i in range(n, n - k, -1)])
s = 0
for i in range(n):
	if p[i] in ss:
		idx.append(i)
		s += p[i]
		ss.discard(p[i])
idx.sort()
ans = 1
for i in range(len(idx) - 1):
	ans = ans * (idx[i + 1] - idx[i]) % m
print(s, ans)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
indc = []
sm = 0
for i in range(n):
	if b[i] > n - k:
		indc.append(i)
		sm += b[i]
otv = 1
for i in range(1, k):
	otv = otv * (indc[i] - indc[i - 1]) % 998244353
print(sm, otv)


(n, k) = map(int, input().split())
pr = list(map(int, input().split()))
yy = 0
for i in range(0, k):
	yy += n - i
li = []
count = 1
for i in range(n):
	if pr[i] >= n - k + 1:
		li.append(i)
li.sort()
for j in range(1, len(li)):
	count *= li[j] - li[j - 1]
print(yy, count % 998244353)


def I():
	return list(map(int, input().split()))
(n, k) = I()
p = I()
s = 0
num = 1
for i in range(k):
	s += n - i
markers = []
for i in range(n):
	if p[i] >= n - k + 1:
		markers.append(i)
nums = 1
for i in range(1, k):
	nums *= markers[i] - markers[i - 1]
	nums %= 998244353
print(s, nums)


import sys
from math import sqrt
inp = sys.stdin.readline

def max_pal(s):
	n = len(s)
	(st, ed) = (0, n - 1)
	m = ed + 1
	flag = 0
	while st < ed:
		if s[st] == s[ed]:
			if st + 2 == ed:
				break
			st += 1
			ed -= 1
			flag = 1
		else:
			if flag:
				st = 0
				flag = 0
			else:
				st = 0
				ed -= 1
			m = ed
	return s[:m + 1]

def max_pal2(s):
	n = len(s)
	res = ''
	i = 0
	j = n - 1
	while s[i] == s[j] and i < j:
		i += 1
		j -= 1
	(p1, p2) = (s[:i], s[j + 1:])
	if p1 and p2:
		(p3, p4) = (max_pal(s[i:j + 1]), max_pal(s[i:j + 1][::-1]))
		p = p3 if len(p3) > len(p4) else p4
		res = p1 + p + p2
	else:
		(p1, p2) = (max_pal(s[i:j + 1]), max_pal(s[i:j + 1][::-1]))
		res = p1 if len(p1) > len(p2) else p2
	return res

def d():
	ans = ''
	for _ in range(int(inp())):
		s = inp().strip()
		res = max_pal2(s)
		if res:
			ans += res + '\n'
		else:
			ans += s[0] + '\n'
	print(ans)

def c():
	(n, k) = map(int, inp().split())
	arr = list(map(int, inp().split()))
	sett = set()
	for i in range(k):
		sett.add(n - i)
	arr2 = []
	for (i, elem) in enumerate(arr):
		if elem in sett:
			arr2.append(i)
	res = 1
	for i in range(1, len(arr2)):
		res *= arr2[i] - arr2[i - 1]
	print(sum(sett), res % 998244353)
c()


def get_vector():
	return list(map(int, input().split()))
(n, k) = get_vector()
b = get_vector()
(indices, lb) = ([], n - k)
for (i, v) in enumerate(b):
	if v > lb:
		indices.append(i)
part_val = (n * (n + 1) - (n - k) * (n - k + 1)) // 2
parts = 1
for i in range(1, len(indices)):
	parts = parts * (indices[i] - indices[i - 1]) % 998244353
print(f'{part_val} {parts}')


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
largest = k * (2 * n - k + 1) // 2
total = 1
i = 0
while p[i] <= n - k:
	i += 1
count = 1
num = 1
i += 1
while count < k:
	if p[i] > n - k:
		total *= num
		total %= 998244353
		num = 1
		count += 1
	else:
		num += 1
	i += 1
print(largest, total)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
mn = n - k + 1
val = sum([i for i in range(mn, n + 1)])
cnt = 1
MOD = 998244353
curr = 0
volt = False
for (i, x) in enumerate(p):
	if x >= mn:
		if not volt:
			volt = True
			curr = 1
		else:
			cnt = cnt * curr % MOD
			curr = 1
	else:
		curr += 1
print(val, cnt)


import sys
import heapq

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

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

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

def main():
	(n, k) = rinput()
	q = rlinput()
	w = []
	for i in range(n):
		heapq.heappush(w, (q[i], i))
		if len(w) == k + 1:
			heapq.heappop(w)
	w = [w[i][1] for i in range(k)]
	w.sort()
	(res, ans) = (0, 1)
	for i in w:
		res += q[i]
	for i in range(k - 1):
		ans = ans * (w[i + 1] - w[i]) % 998244353
	print(res, ans)
for i in range(1):
	main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = ans = q1 = 0
for q in range(n, n - k, -1):
	x += q
for q in range(n):
	if a[q] > n - k:
		(q1, ans) = (q, 1)
		break
for q in range(q1 + 1, n):
	if a[q] > n - k:
		(ans, q1) = (ans * (q - q1) % 998244353, q)
print(x, ans)


def maxPartitionValue(n, k):
	return k * (n + n - k + 1) // 2

def nPossiblePartitions(n, k, permutation):
	(nPartitions, lowLimit) = (1, n - k)
	allMaxValues_Indices = tuple((i for i in range(n) if lowLimit < int(permutation[i]) <= n))
	for i in range(1, len(allMaxValues_Indices)):
		nPartitions = nPartitions * (allMaxValues_Indices[i] - allMaxValues_Indices[i - 1]) % 998244353
	return nPartitions
(n, k) = map(int, input().split(' '))
permutation = input().split(' ')
print(maxPartitionValue(n, k), nPossiblePartitions(n, k, permutation))


(n, k) = map(int, input().split())
ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
d = dict()
nums = [int(i) for i in input().split()]
for i in range(n):
	d[nums[i]] = i
li = []
for i in range(n - k + 1, n + 1):
	li.append(d[i])
li.sort()
ans2 = 1
for i in range(1, len(li)):
	ans2 *= li[i] - li[i - 1]
print(ans1, ans2 % 998244353)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))
mo = 1000000007
(n, k) = value()
a = arr()
d = defaultdict(int)
sm = 0
for i in range(n - k + 1, n + 1):
	d[i] += 1
	sm += i
if n == k:
	print(sm, 1)
else:
	j = -1
	ans = 1
	for i in range(n):
		if a[i] in d:
			if j != -1:
				ans *= (i - j) % 998244353
			j = i
	print(sm, ans % 998244353)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = sorted(l)[::-1]
d = set()
s = 0
for i in range(k):
	s = s + p[i]
	d.add(p[i])
c = 0
ans = 1
i = 0
for i in range(n):
	if c == 0 and l[i] in d:
		prev = i
		c = 1
	elif c == 1 and l[i] in d:
		ans = ans * (i - prev)
		prev = i
print(s, ans % 998244353)


mod = 998244353
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
t = {}
cnt = n
ans = 0
for i in range(k):
	t[cnt] = 0
	ans = ans + cnt
	cnt -= 1
temp = []
for i in range(n):
	if arr[i] in t:
		temp.append(i)
diff = []
for i in range(1, len(temp)):
	diff.append(temp[i] - temp[i - 1])
q = 1
for i in diff:
	q = q % mod * (i % mod) % mod
print(ans, q)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
flag = False
p = 0
s = 0
t = 1
for i in range(n):
	if arr[i] > n - k:
		if not flag:
			flag = True
			s += arr[i]
			p = i
		else:
			t *= i - p
			s += arr[i]
			p = i
print(s, t % 998244353)


import sys
import math
import collections
inp = lambda : sys.stdin.readline()
m = 998244353
(n, k) = map(int, inp().split())
a = list(map(int, inp().split()))
ll = [(a[i], i) for i in range(n)]
ll.sort()
ll = ll[::-1]
ll = ll[:k]
sm = 0
for i in ll:
	sm += i[0]
a = [i[1] for i in ll]
a.sort()
p = 0
ans = 1
for i in range(1, len(a)):
	ans *= a[i] - a[i - 1]
print(sm, ans % m)


import sys
import math
input = sys.stdin.readline
mod = 998244353
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	d = {}
	ans2 = 0
	for i in range(n):
		d[p[i]] = i
	l = []
	for i in range(n, n - k, -1):
		l.append(d[i])
		ans2 += i
	l.sort()
	ans = 1
	for i in range(k - 1):
		ans *= l[i + 1] - l[i]
	print(ans2, ans % mod)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
i1 = 0
i2 = 0
count = 1
sum = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
c = 0
for i in range(0, n):
	if n - k + 1 <= p[i]:
		i1 = i
		break
for i in range(n - 1, -1, -1):
	if n - k + 1 <= p[i]:
		i2 = i
		break
for i in range(i1 + 1, i2 + 1):
	if n - k + 1 <= p[i]:
		c += 1
		count = count % 998244353 * (c % 998244353) % 998244353
		c = 0
	else:
		c += 1
print(str(sum) + ' ' + str(count))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
mod = 998244353
for i in range(n):
	if a[i] > n - k and a[i] <= n:
		b.append(i)
ans = 1
for i in range(1, len(b)):
	ans *= b[i] - b[i - 1]
s = 0
for elem in b:
	s += a[elem]
print(s, ans % mod)


modulo = 998244353
(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
p1 = [(v, i) for (i, v) in enumerate(p)]
p1 = sorted(p1)[::-1][:k]
s = sum([i[0] for i in p1])
p1 = sorted([i[1] for i in p1])
p = 1
for i in range(1, k):
	p *= p1[i] - p1[i - 1]
print(s, p % modulo)


import sys
(n, k) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
lim = n - k
mod = 998244353
g = []
for i in range(n):
	if arr[i] > lim:
		g.append(i)
ans = 1
m = len(g)
for i in range(1, m):
	ans = ans * (g[i] - g[i - 1])
	ans = ans % mod
a = 0
for i in range(n - k + 1, n + 1):
	a += i
print(a, ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
s = ''
for i in range(n):
	if arr[i] > n - k:
		s += '1'
	else:
		s += '0'
s = s.strip('0')
dem = 0
ans = 1
for i in range(len(s)):
	if s[i] == '1':
		ans = ans * (dem + 1) % 998244353
		dem = 0
	else:
		dem += 1
ok = 0
for i in range(n - k + 1, n + 1):
	ok += i
print(ok, end=' ')
print(ans)


import math
import sys
input = sys.stdin.readline
input_list = lambda : list(map(int, input().split()))
MOD = 998244353

def exp(a, n):
	if n == 0:
		return 1
	result = a
	residue = 1
	while n > 1:
		if n % 2 == 1:
			residue = residue * result % MOD
		result = result * result % MOD
	return result * residue % MOD

def main():
	(n, k) = input_list()
	p = input_list()
	a = p.copy()
	pos = []
	a.sort(reverse=True)
	l = 0
	sum = 0
	for i in range(n):
		if a[k - 1] <= p[i]:
			pos.append(i)
			sum += p[i]
	ans = 1
	for i in range(1, k):
		ans = ans * (pos[i] - pos[i - 1]) % MOD
	print(sum)
	print(ans)
main()


from functools import lru_cache

def sol(n, k, arr):
	MOD = 998244353
	s = k * (n + 1 - k + n) // 2
	idx = {a: i for (i, a) in enumerate(arr)}
	pos = sorted((idx[a] for a in range(n + 1 - k, n + 1)))
	res = 1
	for (i, j) in zip(pos, pos[1:]):
		res = res * (j - i) % MOD
	return (s, res)

def main():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	print(' '.join((str(x) for x in sol(n, k, arr))))
main()


(n, k) = input().split()
n = int(n)
k = int(k)
perm = input().split()
max_val = (n + n - k + 1) * k // 2
the_mod = 998244353
num_poss = 1
counter = 0
num_appear = 0
for i in perm:
	counter += 1
	if int(i) > n - k:
		if num_appear != 0:
			num_poss *= counter
			num_poss = num_poss % the_mod
		num_appear += 1
		counter = 0
print(max_val, num_poss)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
l = []
i = 0
while i < n:
	if p[i] >= n - k + 1:
		i += 1
		continue
	j = i
	while j < n and p[j] <= n - k:
		j += 1
	if i != 0 and j != n:
		l.append(j - i)
	i = j
(ansa, ansb) = (0, 1)
for i in range(n, n - k, -1):
	ansa += i
mo = 998244353
for i in l:
	ansb = ansb * (i + 1) % mo
print(ansa, ansb)


(x, y) = map(int, input().split())
z = list(map(int, input().split()))
ans = []
for i in range(len(z)):
	if z[i] > x - y:
		ans.append(i)
ans.sort()
total = 1
for i in range(1, len(ans)):
	total = total % 998244353 * ((ans[i] - ans[i - 1]) % 998244353) % 998244353
al = x * (x + 1) // 2 - (x - y) * (x - y + 1) // 2
print(al, total)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
M = 998244353
C = sorted(range(n), key=lambda sub: A[sub])[-k:]
C.sort()
S = 0
a = 0
P = 1
for i in range(n):
	if i == C[a]:
		a += 1
		S += A[i]
	if a == k:
		break
for i in range(k - 1):
	P = P % M * ((C[i + 1] - C[i]) % M) % M
print(S, P % M)


o = list(map(int, input().split()))
(n, k) = (o[0], o[1])
a = list(map(int, input().split()))
d = dict()
for i in range(n):
	d[a[i]] = i + 1
b = a[:]
b.sort()
b = b[::-1]
ans = list()
sum = 0
for i in range(k):
	sum += b[i]
	ans.append(d[b[i]])
ans.sort()
if k == 1 or k == n:
	print(sum, '1')
elif k == 2:
	print(sum, ans[1] - ans[0])
else:
	l = ans[1] - ans[0]
	l %= 998244353
	i = 1
	while i < k - 1:
		l *= ans[i + 1] - ans[i]
		l %= 998244353
		i += 1
	print(sum, l % 998244353)


modulo = 998244353
(n, k) = [int(i) for i in input().split()]
lst = [int(i) for i in input().split()]
(p, answer, s) = (-1, 1, 0)
for i in range(n):
	if lst[i] > n - k:
		s += lst[i]
		if p != -1:
			answer *= i - p
			answer %= modulo
		p = i
print(s, answer)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
max_value = k * (n - k) + k * (k + 1) // 2
last = -1
ans = 1
for i in range(n):
	if p[i] > n - k and p[i] <= n:
		if last == -1:
			last = i
		else:
			ans *= i - last
			ans = ans % 998244353
			last = i
print(max_value, ans)


import sys

def read():
	return list(map(int, sys.stdin.readline().rstrip().split(' ')))
(n, k) = read()
p = read()
x = 0
y = 1
prev = None
for i in range(n):
	if p[i] > n - k:
		x += p[i]
		if prev is not None:
			y *= i - prev
		prev = i
y = y % 998244353
print(x, y)


def STR():
	return list(input())

def INT():
	return int(input())

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush, heapify
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
n = LIST()
a = LIST()
k = n[1]
x = []
heapify(x)
for i in range(len(a)):
	if len(x) < k:
		heappush(x, [a[i], i])
	elif x[0][0] < a[i]:
		heappop(x)
		heappush(x, [a[i], i])
z = []
ans1 = 0
for i in x:
	ans1 += i[0]
	z.append(i[1])
z.sort()
ans2 = 1
for i in range(1, len(z)):
	ans2 *= z[i] - z[i - 1]
print(ans1, ans2 % 998244353)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
kk = 1
m = 998244353
bnd = n - k + 1
i = 0
while i < n and a[i] < bnd:
	i += 1
s = 0
cnt = 0
for j in range(n - k + 1, n + 1):
	s += j
	cnt += 1
i += 1
c = 1
while i < n and c < cnt:
	j = 1
	c += 1
	while i < n and a[i] < bnd:
		j += 1
		i += 1
	kk = kk * j % m
	i += 1
print(s, kk)


import math
(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
topk = [i for i in range(n) if nums[i] > n - k]
m = len(topk)
ans = 1
ans1 = 0
for i in range(m - 1):
	ans *= topk[i + 1] - topk[i]
	ans %= 998244353
for i in range(n - k + 1, n + 1):
	ans1 += i
print('%d %d' % (ans1, ans))


import sys
input = sys.stdin.readline
MOD = 998244353
(n, k) = map(int, input().split())
p = [int(item) for item in input().split()]
lim = n - k
cnt = 0
ans = 1
initialized = False
for item in p:
	if item <= lim:
		cnt += 1
	else:
		if initialized:
			ans *= cnt
			ans %= MOD
		initialized = True
		cnt = 1
total = k * (2 * n - (k - 1)) // 2
print(total, ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
i = 0
prod = 1
bet = n - k + 1
summ = 0
cnt = 1
point = 0
mod = 998244353
while i < n:
	if p[i] >= bet:
		summ += p[i]
		if point >= 1:
			prod = prod * cnt % mod
		point += 1
		cnt = 1
	else:
		cnt += 1
	i += 1
print(summ, prod)


import sys
input = sys.stdin.readline
mod = 998244353
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
P = []
ans1 = 0
for (i, a) in enumerate(A):
	if a >= N - K + 1:
		ans1 += a
		P.append(i)
ans2 = 1
for i in range(len(P) - 1):
	d = P[i + 1] - P[i]
	ans2 = ans2 * d % mod
print(ans1, ans2)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()

def iin():
	return int(input())

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

def main():
	T = 1
	while T:
		T -= 1
		md = 998244353
		(n, k) = lin()
		p = lin()
		a1 = {*range(n - k + 1, n + 1)}
		sm = sum(list(a1))
		a = [0] + [1 if i in a1 else 0 for i in p] + [0]
		i = 0
		ans = 1
		a1 = []
		n = len(a)
		while i < n:
			ch = 1
			while i < n and a[i] != 1:
				ch += 1
				i += 1
			i += 1
			a1.append(ch)
		a1 = a1[1:-1]
		for i in a1:
			ans = ans * i % md
		print(sm, ans)
main()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
mod = 998244353
maxi = 0
for i in range(n - k + 1, n + 1):
	maxi += i
i = 0
while p[i] < n - k + 1:
	i += 1
bignumbers = 1
sol = 1
interval = 0
i += 1
while bignumbers < k:
	if p[i] < n - k + 1:
		interval += 1
	else:
		bignumbers += 1
		sol *= interval + 1
		interval = 0
		sol = sol % mod
	i += 1
print(maxi, sol)


(n, k) = (int(s) for s in input().split(' '))
ps = [int(s) for s in input().split(' ')]
max_value = (n - k) * k + k * (k + 1) // 2
min_good_number = n - k + 1
product = 1
if k > 1:
	good_indices = [i for i in range(n) if ps[i] >= min_good_number]
	pairs_of_good_indices = tuple(zip(good_indices[:-1], good_indices[1:]))
	for (l_ind, r_ind) in pairs_of_good_indices:
		ways = r_ind - l_ind
		product *= ways
		product %= 998244353
print(max_value, product)


mod = 998244353
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	value = (2 * n - k + 1) * k // 2
	pos = []
	for i in range(n):
		if n - k < a[i] <= n:
			pos.append(i)
	ways = 1
	for i in range(1, len(pos)):
		ways = ways * (pos[i] - pos[i - 1]) % mod
	print(value, ways)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
L = []
s = n * (n + 1) / 2
m = 1
x = n - k
s -= x * (x + 1) / 2
if n == k:
	print(int(s), m)
else:
	for i in range(n):
		if p[i] > x:
			L.append(i + 1)
	for i in range(0, k):
		if i == k - 1:
			pass
		else:
			m *= L[i + 1] - L[i]
	m %= 998244353
	print(int(s), m)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = sorted(l, reverse=True)
d = {}
s = 0
for i in range(k):
	d[a[i]] = 1
	s += a[i]
pos = []
for i in range(n):
	try:
		d[l[i]] += 0
		pos.append(i)
	except:
		1 == 1
bl = 1
for i in range(len(pos) - 1):
	bl *= pos[i + 1] - pos[i]
print(s, bl % 998244353)


import sys
import bisect
from collections import defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
(n, k) = sp()
p = l()
if n == k:
	print(sum(p), 1)
elif k == 1:
	print(max(p), 1)
else:
	(i, tots, j, g) = (n - 1, 0, 0, 1)
	b = []
	c = dd(lambda : 0)
	for i in range(n):
		c[p[i]] = i
	p.sort()
	while j < k:
		b.append(c[p[i]])
		(tots, i, j) = (tots + p[i], i - 1, j + 1)
	b.sort()
	for i in range(len(b) - 1):
		g *= b[i + 1] - b[i]
	print(tots, g % 998244353)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
el = k * (n + n - k + 1) // 2
yes = 0
ans = 1
mod = 998244353
counter = 0
for i in range(n):
	if n - k < a[i] and yes == 0:
		counter = 1
		yes = 1
	elif n - k < a[i]:
		ans *= counter
		counter = 1
		ans %= mod
	else:
		counter += 1
print(el, ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
max_value = 0
prev = -1
for i in range(n):
	if a[i] >= n - k + 1:
		if prev != -1:
			ans = ans * (i - prev) % 998244353
		max_value += a[i]
		prev = i
print(max_value, ans)


import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
p = [int(i) for i in input().split()]
p_ = sorted(p)[::-1]
print(sum(p_[:k]), end=' ')
mn = min(p_[:k])
mul = [1]
for i in range(n):
	if p[i] >= mn:
		mul.append(1)
	else:
		mul[-1] += 1
ans = 1
if p[0] < mn:
	mul[0] = 1
if p[-1] < mn:
	mul[-1] = 1
for i in mul:
	ans = ans * i % 998244353
print(ans)


(n, k) = map(int, input().split())
ind = {i + 1: 0 for i in range(1, n + 1)}
a = list(map(int, input().split()))
for i in range(n):
	ind[a[i]] = i
fi = 0
r = []
for i in range(n, n - k, -1):
	fi += i
	r.append(ind[i])
r.sort()
se = 1
p = 998244353
for i in range(len(r) - 1):
	se = se * abs(r[i] - r[i + 1]) % p
print(fi, se)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	MOD = 998244353
	(n, k) = MI()
	p = LI()
	s = 0
	ind = []
	res = 1
	for i in range(n):
		if p[i] >= n - k + 1:
			ind.append(i)
			s += p[i]
	for i in range(1, k):
		res *= ind[i] - ind[i - 1]
		res %= MOD
	print(s, res)
main()


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
max_val = sum(range(n, n - k, -1))
num_perm = 1
last_idx = -1
for i in range(n):
	if p[i] > n - k:
		if last_idx != -1:
			num_perm *= i - last_idx
		last_idx = i
print(max_val, end=' ')
print(num_perm % 998244353)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = (n - k) * k + k * (k + 1) / 2
ar = []
for i in range(n):
	if l[i] > n - k:
		ar.append(i)
fa = 1
p = len(ar)
for i in range(p):
	if i < p - 1:
		fa = fa * (ar[i + 1] - ar[i]) % 998244353
print(int(ans), fa)


from collections import Counter
from collections import defaultdict
import math
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = sorted(a, reverse=True)
d = defaultdict(lambda : 0)
sm = 0
for i in range(0, k):
	sm = sm + l[i]
	d[l[i]] = 1
ans = []
for i in range(0, n):
	if d[a[i]] == 1:
		ans.append(i)
ans.sort()
s = 1
for i in range(1, k):
	s = s * (ans[i] - ans[i - 1])
print(sm, s % 998244353)


(n, k) = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
mod = 998244353
x = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
prev = 0
ans = []
ans1 = 1
for i in range(1, n + 1):
	if a[i] <= n and a[i] >= n - k + 1:
		ans.append(i)
for i in range(len(ans) - 1):
	ans1 *= ans[i + 1] - ans[i]
print(x, ans1 % mod)


(n, k) = list(map(int, input().split()))
Ps = list(map(int, input().split()))
maxval = (2 * n - k + 1) * k // 2
maxx = n
minn = n - k + 1
count = 1
result = 1
middle = False
for each in Ps:
	if minn <= each and each <= maxx:
		if middle:
			result = result * count % 998244353
		else:
			middle = True
		count = 1
	else:
		count += 1
print(maxval, result)


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, k) = Read.list_int()
	a = Read.list_int()
	s = 0
	for i in range(k):
		t = n - i
		s += t
	f = n - k + 1
	r2 = 1
	j = False
	k = 1
	for i in a:
		if i >= f:
			if j:
				r2 = r2 * k
				r2 = r2 % 998244353
			j = True
			k = 1
		elif j == True:
			k += 1
	print(str(s) + ' ' + str(r2))
query_count = 1
while query_count:
	query_count -= 1
	solve()


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
s = k * n - k * (k - 1) // 2
d = set()
for i in range(k):
	d.add(n - i)
ans = 1
for i in range(n):
	if x[i] in d:
		ref = i
		break
for j in range(i + 1, n):
	if x[j] in d:
		ans = ans * ((j - ref) % 998244353)
		ref = j
print(s, ans % 998244353)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)
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')

def find_parent(parent, i, cnt):
	cnt += 1
	if parent[i - 1] == i:
		return cnt
	if parent[i - 1] != i:
		find_parent(parent, parent[i - 1], cnt)
from collections import Counter
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
var = n * m - (m - 1) * m // 2
pos = []
for i in range(n):
	if arr[i] >= n + 1 - m and arr[i] <= n:
		pos.append(i)
pos.sort()
var1 = 1
for i in range(len(pos) - 1):
	var1 *= pos[i + 1] - pos[i]
	var1 %= 998244353
print(var, var1)


data = input().rstrip().split()
(n, k) = (int(data[0]), int(data[1]))
N = 998244353
s = 0
prev = 0
p = 1
c = 0
data = input().rstrip().split()
bb = [int(d) for d in data]
for (i, b) in enumerate(bb):
	if b > n - k:
		s += b
		if c > 0:
			p = p * (i - prev) % N
		c += 1
		prev = i
print(str(s) + ' ' + str(p))


from math import factorial
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(A)
A.sort(reverse=True)
ans = 0
for i in range(m):
	ans += A[i]
	kek = A[i]
ans2 = 1
last = -1
for i in range(n):
	if B[i] >= kek:
		if last != -1:
			ans2 *= i - last
			ans2 %= 998244353
		last = int(i)
print(ans, ans2)


(n, k) = map(int, input().split())
ll = list(map(int, input().split()))
mas_ukaz = []
smm = 0
ans1 = 1
for i in range(n):
	if n - k + 1 <= ll[i]:
		mas_ukaz.append(i)
		smm += ll[i]
mod = 998244353
for i in range(k - 1):
	rast = mas_ukaz[i + 1] - mas_ukaz[i]
	if rast == 0:
		continue
	else:
		ans1 = rast * ans1 % mod
print(smm, max(ans1, 1))


(N, M) = map(int, input().split())
idx = [0] * N
for (i, x) in enumerate(map(int, input().split())):
	idx[x - 1] = i
f = lambda x: x * (x + 1) // 2
ans1 = f(N) - f(N - M)
ans2 = 1
L = []
for i in range(N - M, N):
	L.append(idx[i])
L.sort()
mod = 998244353
for i in range(M - 1):
	ans2 = ans2 * (L[i + 1] - L[i]) % mod
print(ans1, ans2)


import sys

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

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

def input():
	return sys.stdin.readline().strip()
(n, k) = ilele()
A = alele()
t = 0
z = n
mark = {}
for i in range(k):
	t += z
	mark[z] = 1
	z -= 1
	if z == 0:
		break
M = 998244353
l = None
Ans = 1
for i in range(len(A)):
	if l == None:
		if mark.get(A[i], -1) == 1:
			l = 1
	elif mark.get(A[i], -1) == 1:
		Ans *= l
		l = 1
		Ans %= M
	else:
		l += 1
print(t, Ans % M)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = []
for (i, v) in enumerate(p):
	if v > n - k:
		q.append(i)
r = 1
for i in range(1, len(q)):
	r *= q[i] - q[i - 1]
print((2 * n - k + 1) * k // 2, r % 998244353)


m = 998244353
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
s = 0
correct = set()
for i in range(k):
	s += n - i
	correct.add(n - i)
gaps = []
prev = -1
for i in range(n):
	if ar[i] in correct:
		if prev == -1:
			prev = i
		else:
			gaps.append(i - prev - 1)
			prev = i
s2 = 1
for i in gaps:
	s2 = s2 * (i + 1) % m % m
print(s, s2 % m)


nk = input().split()
n = int(nk[0])
k = int(nk[1])
p = input().split()
for num in range(n):
	p[num] = int(p[num])
high = []
d = []
for num in range(n):
	if p[num] - (n - k) > 0:
		high.append(num)
total = 1
for num in range(k - 1):
	total = total * (high[num + 1] - high[num])
	total = total % 998244353
print(int((2 * n * k + (1 - k) * k) / 2))
print(total % 998244353)


from sys import stdin, stdout
arr = [int(i) for i in stdin.readline().split()]
(n, k) = (arr[0], arr[1])
mod = 998244353
(a, p, s) = (1, -1, 0)
arr = [int(i) for i in stdin.readline().split()]
for i in range(len(arr)):
	x = arr[i]
	if x >= n - k + 1:
		if p != -1:
			a = a * ((i - p) % mod) % mod
		s += x
		p = i
print(str(s) + ' ' + str(a))


(n, k) = map(int, input().split())
a = [*map(int, input().split())]
MOD = 998244353
from collections import defaultdict
idx = defaultdict(int)
for (i, j) in enumerate(a):
	idx[j] = i
a.sort(reverse=True)
ans = 0
count = 1
indices = []
for i in range(k):
	ans += a[i]
	indices.append(idx[a[i]])
indices.sort()
for i in range(1, len(indices)):
	count = count * (indices[i] - indices[i - 1]) % MOD
print(ans, count)


from sys import stdin
inp = stdin.readline
(n, k) = map(int, inp().split())
p = list(map(int, inp().split()))
h = p[:]
h.sort(reverse=True)
mp = {}
ans = 0
for i in range(k):
	mp[h[i]] = 1
	ans += h[i]
P = 998244353
flag = 0
val = 1
count = 1
for i in range(n):
	if p[i] in mp:
		val = val * count % P
		count = 1
		flag = 1
		continue
	if flag == 1:
		count += 1
print(ans, val)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
s1 = []
t = n
for i in range(n):
	if len(s1) == k:
		break
	if n - k < l[i] <= n:
		s1.append(i)
		t = t - 1
pr = 1
for i in range(1, len(s1)):
	pr = pr * (s1[i] - s1[i - 1])
print(s, pr % 998244353)


(n, k) = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
m = 998244353
index_dict = {}
i = 1
for x in p:
	index_dict[x] = i
	i += 1
p.sort()
required_indices = []
required_values = []
ans_sum = 0
ans_possiblities = 1
temp = p[::-1]
for i in range(k):
	required_values.append(temp[i])
	required_indices.append(index_dict[temp[i]])
	ans_sum += temp[i]
required_indices.sort()
for i in range(1, len(required_indices)):
	ans_possiblities *= required_indices[i] - required_indices[i - 1]
	ans_possiblities = ans_possiblities % m
print(ans_sum, ans_possiblities % m)


M = 998244353

def solve(n, k, a):
	ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
	ans2 = 0
	c = 0
	for ai in a:
		if ai <= n - k:
			c += 1
		else:
			if ans2 == 0:
				ans2 = 1
			else:
				ans2 = ans2 * (c + 1) % M
			c = 0
	print(ans1, ans2)

def main():
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	solve(n, k, a)
main()


def fun1(a):
	return a[0]

def fun2(a):
	return a[1]
modulo = 998244353
a = input().split()
n = int(a[0])
k = int(a[1])
a = input().split()
b = []
for i in range(n):
	b.append([int(a[i]), i])
b.sort(key=fun1, reverse=True)
sum = 0
c = b[:k]
for i in range(k):
	sum += b[i][0]
c.sort(key=fun2)
result = 1
for i in range(1, k):
	result = result * (c[i][1] - c[i - 1][1]) % modulo
print(sum, result)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
pos = []
MOD = 998244353
ss = 0
for i in range(len(arr)):
	if arr[i] >= n - k + 1:
		pos.append(i)
		ss += arr[i]
ans = 1
for i in range(1, len(pos)):
	ans = ans * (pos[i] - pos[i - 1]) % MOD
print(ss, ans)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
l = 0
for i in range(n - k + 1, n + 1):
	l += i
s = 1
a = 0
j = 0
while j < n:
	if p[j] >= n - k + 1:
		break
	j += 1
for i in range(j + 1, n):
	a += 1
	if p[i] >= n - k + 1:
		s *= a
		a = 0
print(l, s % 998244353)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
ind = [-1] * n
for i in range(n):
	ind[arr[i] - 1] = i
z = 998244353
ans = 1
lis = []
num = 0
p = n
for i in range(k):
	lis.append(ind[-i - 1])
	num += p
	p -= 1
lis.sort()
for i in range(k - 1):
	ans *= lis[i + 1] - lis[i]
	ans %= z
print(num, 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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = [0] * n
d = dict()
for i in range(n):
	s[i] = l[i]
	d.update({l[i]: i})
l.sort(reverse=True)
ind = [0] * k
su = 0
for i in range(k):
	ind[i] = d[l[i]]
	su += l[i]
ind.sort()
ans1 = 1
for i in range(1, k):
	ans1 *= (ind[i] - ind[i - 1]) % 998244353
print(su, ans1 % 998244353)


(n, k) = map(int, input().split())
plist = list(map(int, input().split()))
ans = []
sum = 0
for i in range(n):
	if plist[i] >= n - k + 1:
		sum += plist[i]
		pos = i
		ans.append(pos)
cnt = 1
for j in range(len(ans) - 1):
	cnt *= (ans[j + 1] - ans[j]) % 998244353
print(sum, cnt % 998244353)


(n, k) = map(int, input().split())
value = 0
total = 1
count = 1
for pp in map(int, input().split()):
	if pp > n - k:
		value += pp
		total = total * count % 998244353
		count = 1
	elif value:
		count += 1
print(f'{value} {total}')


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
	if A[i] > n - k:
		A[i] = '-'
chunks_lens = list()
l = 0
for it in A:
	if it == '-':
		chunks_lens.append(l)
		l = 0
	else:
		l += 1
chunks_lens.append(0)
res = 1
for i in range(1, k):
	if chunks_lens[i] != 0:
		res *= chunks_lens[i] + 1
		res %= 998244353
print((n - k + 1 + n) * k // 2, res)


input_line = input()
parts = input_line.strip().split(' ')
(n, k) = (int(parts[0]), int(parts[1]))
input_line = input()
parts = input_line.strip().split(' ')
permutation = [int(v) for v in parts]
value_to_index = {}
for index in range(n):
	value_to_index[permutation[index]] = index
indices = []
ans = 0
mod = 998244353
sorted_permutation = sorted(permutation)
for i in range(k):
	value = n - i
	indices.append(value_to_index[value])
	ans += value
sorted_indices = sorted(indices)
count = 1
for i in range(1, k):
	count *= sorted_indices[i] - sorted_indices[i - 1]
	count %= mod
print(ans, count, end=' ')


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')
values = list(map(int, input().split()))
n = values[0]
k = values[1]
perms = list(map(int, input().split()))
indices = []
for j in range(n):
	if perms[j] > n - k:
		indices.append(j)
indices.sort()
cumprod = 1
for b in range(len(indices) - 1):
	cumprod = cumprod * (indices[b + 1] - indices[b])
	cumprod = cumprod % 998244353
max1 = 0
for i in range(k):
	max1 += n - i
print(str(max1) + ' ' + str(cumprod))


(n, k) = input().split()
n = int(n)
k = int(k)
arr = input().split()
value = (n - k + 1 + n) * k // 2
min_target = n - k + 1
max_target = n
chunks = [0 for _ in range(k + 1)]
c_index = 0
for (idx, ele) in enumerate(arr):
	if min_target <= int(ele) and int(ele) <= max_target:
		c_index += 1
	else:
		chunks[c_index] += 1
for (i, ele) in enumerate(chunks):
	if i == 0 or i == len(chunks) - 1 or ele == 0:
		chunks[i] = 1
	else:
		chunks[i] += 1
from functools import reduce
ans = reduce(lambda x, y: x * y, chunks)
ans = ans % 998244353
print(str(value) + ' ' + str(ans))


from sys import stdin
mod = 998244353
(n, k) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
ans = []
M = n
m = n - k + 1
s = 0
for i in range(n):
	if arr[i] >= m and arr[i] <= M:
		s += arr[i]
		ans.append(i)
if len(ans) == 1:
	print(s, 1)
else:
	a = 1
	for i in range(1, len(ans)):
		a = a * (ans[i] - ans[i - 1]) % mod
	print(s, a)


(N, K) = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
MOD = 998244353
value = int(N * (N + 1) / 2 - (N - K) * (N - K + 1) / 2)
count = 1
last_eli = None
for i in range(N):
	if P[i] <= N - K:
		continue
	if last_eli is not None:
		count = count * (i - last_eli) % MOD
	last_eli = i
print(value, count)


(n, k) = map(int, input().split())
lst = [int(i) for i in input().split()]
max_lst = lst[0:]
max_lst.sort(reverse=True)
(max_set, total) = (set(max_lst[:k]), sum(max_lst[:k]))
(last, ans) = (-1, 1)
for i in range(n):
	if lst[i] in max_set:
		if last >= 0:
			ans *= i - last
			ans %= 998244353
		last = i
print('{} {}'.format(str(total), str(ans)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
b = [0] * n
arr = [0] * n
for i in range(0, n):
	b[a[i] - 1] = i
for i in range(n - k, n):
	arr[b[i]] += 1
flag = False
temp = 1
for i in range(0, n):
	if flag == False and arr[i] == 1:
		flag = True
	elif flag == True and arr[i] == 0:
		temp += 1
	elif flag == True and arr[i] == 1:
		ans *= temp
		ans %= 998244353
		temp = 1
ss = 0
for i in range(n, n - k, -1):
	ss += i
print(ss, ans)


from math import factorial
(n, k) = map(int, input().split())
dic = {}
p = []
val = list(map(int, input().split()))
for i in range(n):
	dic[val[i]] = i + 1
	p.append(val[i])
newp = sorted(p, reverse=True)
mod = 998244353
vals = newp[:k]
ans1 = sum(vals)
ans2 = 1
ind = []
for i in vals:
	ind.append(dic[i])
ind.sort()
for i in range(len(ind) - 1):
	ans2 *= ind[i + 1] - ind[i]
	ans2 %= mod
if k == n:
	exit(print(ans1, 1))
print(ans1, ans2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
MOD = 998244353
last = n - k + 1
sume = 0
care = []
res = 1
for i in range(n):
	if p[i] >= last:
		care.append(i)
		sume += p[i]
for i in range(1, k):
	res *= care[i] - care[i - 1]
	res %= MOD
print(sume, res)


(n, k) = map(int, input().split())
li = list(map(int, input().split()))
maxm = 0
totalPossible = 1
prev = -1
for i in range(n):
	if li[i] >= n - k + 1:
		maxm += li[i]
		if prev != -1:
			totalPossible *= i - prev
			totalPossible %= 998244353
		prev = i
print(maxm, totalPossible % 998244353)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
d = {p[i]: i for i in range(n)}
temp = sorted(p, reverse=True)
ans1 = sum(temp[:k])
ind = []
for i in temp[:k]:
	ind.append(d[i])
ind.sort()
ans2 = 1
for i in range(k - 1):
	ans2 *= ind[i + 1] - ind[i]
	ans2 = ans2 % 998244353
print(ans1, ans2)


MODULO = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
max_value = 0
for i in range(k):
	max_value += n - i
indices = []
for i in range(n):
	if p[i] > n - k:
		indices.append(i)
ans = 1
for i in range(k - 1):
	ans *= indices[i + 1] - indices[i]
	ans %= MODULO
print(max_value, ans)


(n, k) = map(int, input().split())
P = list(map(int, input().split()))
mod = 998244353
C = []
cnt = 0
flag = False
for i in range(n):
	if P[i] >= n - k + 1:
		if flag and cnt:
			C.append(cnt + 1)
		cnt = 0
		flag = True
	elif flag:
		cnt += 1
s = 0
for i in range(k):
	s += n - i
if len(C) == 0:
	print(s, 1)
else:
	t = 1
	for i in range(len(C)):
		t *= C[i] % mod
	print(s, t % mod)


(n, k) = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
mn = n - k + 1
ind = []
s = 0
for i in range(n):
	if d[i] >= mn:
		ind.append(i)
		s += d[i]
mod = 998244353
ans = 1
for i in range(k - 1):
	ans = ans * (ind[i + 1] - ind[i]) % mod
print(s, ans)


(n, k) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
print(int(0.5 * n * (n + 1) - 0.5 * (n - k) * (n - k + 1)), end=' ')
Is = []
for i in range(n):
	if a[i] > n - k:
		Is.append(i)
com = 1
for j in range(1, k):
	com *= Is[j] - Is[j - 1]
	com %= 998244353
print(com)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
m = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
x = n - k
p = 1
mod = 998244353
i = 0
count = 1
verif = 0
while i < n:
	if arr[i] <= x:
		count += 1
	elif verif:
		p = p * count % mod
		count = 1
	else:
		verif = 1
		count = 1
	i += 1
print(m, p)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
a = k * (n + (n - k + 1)) // 2
b = 1
mod = 998244353
d = []
for (i, x) in enumerate(p):
	if x > n - k:
		d.append(i)
dd = [d[i + 1] - d[i] for i in range(len(d) - 1)]
for x in dd:
	b *= x
	b %= mod
print(a, b)


(N, K) = map(int, input().split())
Arr = list(map(int, input().split()))
indices = []
Sum = 0
for i in range(0, len(Arr)):
	if Arr[i] > N - K:
		Sum = Sum + Arr[i]
		indices.append(i)
prod = 1
prev = 0
for i in range(1, len(indices)):
	prod = prod * (indices[i] - indices[prev]) % 998244353
	prev = i
print(str(Sum) + ' ' + str(prod))


a = [int(x) for x in input().split()]
n = a[0]
k = a[1]
p = [int(x) for x in input().split()]
answer = 1
ans = 0
prev = -1
for i in range(n):
	if p[i] > n - k:
		ans += p[i]
		if prev != -1:
			answer *= i - prev
			answer %= 998244353
		prev = i
print(str(ans) + ' ' + str(answer))


(n, k) = map(int, input().split())
i = 1
p = []
prev = -1
ans = 1
s = 0
m = 998244353
for x in input().split():
	if int(x) >= n - k + 1:
		s += int(x)
		if prev != -1:
			ans = ans * (i - prev) % m
		prev = i
	i += 1
print(s, ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sorted_a = sorted(a, reverse=True)
max_value = sum(sorted_a[:k])
myset = set(sorted_a[:k])
indices = []
for i in range(n):
	if a[i] in myset:
		indices.append(i)
seg = []
for i in range(1, len(indices)):
	seg.append(indices[i] - indices[i - 1])
ans = 1
for x in seg:
	ans = ans * x % 998244353
print(max_value, ans)


(n, k) = [int(i) for i in input().split()]
lenght = 0
ans = 1
mas = [int(i) for i in input().split()]
s = set()
for i in enumerate(reversed(sorted(mas))):
	if i[0] == k:
		break
	s.add(i[1])
	lenght += i[1]
left = 0
right = n - 1
for left in range(0, n - 1):
	if mas[left] in s:
		break
for right in range(n - 1, -1, -1):
	if mas[right] in s:
		break
dist = list()
now = 0
for i in range(left + 1, n):
	if mas[i] not in s:
		now += 1
	else:
		if now == 0:
			continue
		dist.append(now + 1)
		now = 0
for i in dist:
	ans *= i
	ans %= 998244353
print(lenght, ans)


x = input()
xx = x.split()
n = int(xx[0])
k = int(xx[1])
r = int(k * n - 0.5 * k * (k - 1))
x = input()
xx = x.split()
g1 = 0
for i in range(0, n):
	if int(xx[i]) >= n - k + 1:
		g1 = i
		break
g2 = 0
for i in range(n - 1, -1, -1):
	if int(xx[i]) >= n - k + 1:
		g2 = i
		break
s = 1
f = 1
for i in range(g1 + 1, g2 + 1):
	if int(xx[i]) < n - k + 1:
		f += 1
	else:
		s *= f
		f = 1
print(r, end=' ')
print(int(s % 998244353))


import math
(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
ka = set([i for i in range(n, n - k, -1)])
x = -1
y = -1
p = 1
for i in range(n):
	if l[i] in ka:
		if x == -1:
			x = i
		elif y == -1:
			y = i
			p *= y - x
		else:
			x = y
			y = i
			p *= y - x
print(sum(ka), p % 998244353)


(t, n) = map(int, input().split())
arr = [int(i) for i in input().split()]
mx = [0 for i in range(n)]
j = 0
for i in range(t):
	if arr[i] <= t and arr[i] > t - n:
		mx[j] = i
		j += 1
tot = 0
dis = 1
mod = 998244353
for i in range(n):
	tot = tot + (t - i)
for i in range(1, n):
	dis = dis * (mx[i] - mx[i - 1])
	dis = dis % mod
print(tot, dis, end=' ')


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

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

def T(n):
	return n * (n + 1) // 2

def S(a, b):
	return T(b) - T(a - 1)

def solve():
	(n, k) = rl()
	P = rl()
	mod = 998244353
	M = S(n - k + 1, n)
	low = n - k + 1
	prev = -1
	ways = 1
	for (i, p) in enumerate(P):
		if p >= low:
			if prev != -1:
				ways = ways * (i - prev) % mod
			prev = i
	print(M, ways)
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
d = n - k + 1
s = 0
d1 = 1
tr = 0
for i in range(n):
	if a[i] >= d:
		s += a[i]
		if tr == 1:
			d1 = (i - t1) * d1
		tr = 1
		t1 = i
print(s, d1 % 998244353)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
total = (n + n - k + 1) / 2 * k
for i in range(n):
	if l[i] > n - k:
		(prev, ans) = (i, 1)
		break
for i in range(prev + 1, n):
	if l[i] > n - k:
		(ans, prev) = (ans * (i - prev), i)
print(int(total), ans % 998244353)


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
mod = 998244353
debugging = 1
(n, k) = intsput()
p = list(intsput())
mp = {}
for i in range(n):
	mp[p[i]] = i
p_copy = p[:]
p_copy.sort(reverse=True)
val = 0
picks = []
for i in range(k):
	val += p_copy[i]
	picks.append(p_copy[i])
indexes = [mp[i] for i in picks]
indexes.sort()
comb = 1
for idx_idx in range(1, len(indexes)):
	comb *= indexes[idx_idx] - indexes[idx_idx - 1]
	comb %= mod
print(val, comb)


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

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

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

def main():
	(n, k) = lint()
	l = lint()
	mark = [0] * n
	(start, end) = (n - 1, 0)
	ans1 = 0
	for i in range(n):
		if l[i] > n - k:
			mark[i] = 1
			start = min(start, i)
			end = max(end, i)
			ans1 += l[i]
	ans2 = 1
	cnt = 0
	for i in range(start, end + 1):
		if mark[i] == 1:
			ans2 = ans2 * (cnt + 1) % 998244353
			cnt = 0
		else:
			cnt += 1
	print(ans1, ans2)
for i in range(t):
	main()


from sys import stdin, stdout
import math
import random

def main():
	(n, k) = list(map(int, stdin.readline().split()))
	p = list(map(int, stdin.readline().split()))
	m = 998244353
	largest = set(range(n, n - k, -1))
	indexes = list()
	for i in range(n):
		if p[i] in largest:
			indexes.append(i)
	possibilities = 1
	for i in range(1, len(indexes)):
		possibilities *= (indexes[i] - indexes[i - 1]) % m
	possibilities = possibilities % m
	print(sum(largest), possibilities)
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, k) = LI()
		a = LI()
		b = n - k + 1
		t = (b + n) * k // 2
		u = 1
		s = -1
		for (i, c) in enumerate(a):
			if c < b:
				continue
			if s >= 0:
				u *= i - s
				u %= mod2
			s = i
		rr.append(JA([t, u], ' '))
	return JA(rr, '\n')
print(main())


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
MAX = 0
Count = 1
List = []
for i in range(n):
	if p[i] > n - k:
		List.append(i)
		MAX += p[i]
for i in range(len(List) - 1):
	Count = Count * (List[i + 1] - List[i]) % 998244353
print(MAX, Count)


[n, k] = list(map(int, input().split()))
arr = list(map(int, input().split()))
par_val = k * (2 * n - k + 1) // 2
(prev, ways) = (0, 1)
while arr[prev] < n - k + 1:
	prev += 1
start = prev + 1
for idx in range(start, n):
	if arr[idx] > n - k:
		ways *= idx - prev
		prev = idx
print(par_val, ways % 998244353)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	arr = []
	for i in range(n):
		if a[i] > n - k:
			arr.append(i)
	add = 0
	ans = 1
	arr.sort()
	for i in range(1, len(arr)):
		ans *= arr[i] - arr[i - 1]
		add += a[arr[i]]
	add += a[arr[0]]
	print(add, ans % 998244353)
	return
main()


md = 998244353

def f(a):
	return a * (a + 1) // 2
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
if n == k:
	su = f(n)
else:
	su = f(n) - f(n - k)
cnt = 1
a = []
for i in range(n):
	ele = arr[i]
	if ele > n - k:
		a.append(i)
for i in range(1, len(a)):
	cnt = (a[i] - a[i - 1]) % md * (cnt % md) % md
print(su, cnt)


def run_length_compress(string):
	string.append(-1)
	n = len(string)
	begin = 0
	end = 1
	cnt = 1
	ans = []
	while True:
		if end >= n:
			break
		if string[begin] == string[end]:
			end += 1
			cnt += 1
		else:
			ans.append((cnt, string[begin]))
			begin = end
			end = begin + 1
			cnt = 1
	return ans
import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
MOD = 998244353
max_ans = 0
tmp = n
set_ = set([])
for i in range(k):
	max_ans += tmp
	set_.add(tmp)
	tmp -= 1
for i in range(n):
	if p[i] in set_:
		p[i] = 1
	else:
		p[i] = 0
comp = run_length_compress(p)
ans = 1
for (i, num) in enumerate(comp):
	if i == 0 or len(comp) - 1 == i:
		continue
	(tmp, val) = num
	if val == 1:
		continue
	ans *= tmp + 1
	ans %= MOD
print(max_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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	start = n - k + 1
	end = n
	ans = start * (end - start + 1) + (end - start) * (end - start + 1) // 2
	ind = []
	for i in range(n):
		if start <= a[i] <= end:
			ind += [i - 1]
	ans2 = 1
	mod = 998244353
	for i in range(1, len(ind)):
		ans2 = ans2 * (ind[i] - ind[i - 1]) % mod
	print(ans, ans2 % mod)


import atexit
import io
import sys
(n, k) = input().split()
p = input().split()
n = int(n)
k = int(k)
p = list(map(int, p))
maxV = sorted(p, reverse=True)[0:k]
maxVIndices = sorted(sorted(range(len(p)), key=lambda i: p[i])[-k:])
totalCount = 1
for (x, val) in enumerate(maxVIndices):
	if x == len(maxVIndices) - 1:
		continue
	if maxVIndices[x + 1] - val == 1:
		continue
	totalCount = totalCount * (maxVIndices[x + 1] - val)
if n == k:
	totalCount = 1
print(str(sum(maxV)) + ' ' + str(totalCount % 998244353))


from io import BytesIO
import os
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
ans = n * (n + 1) - (n - k) * (n - k + 1)
print(ans // 2, end=' ')
first = 0
for i in range(n):
	if n - k < a[i]:
		first = i
		break
space = 1
t = []
for j in range(first, n):
	if a[j] > n - k:
		t.append(space)
		space = 1
	else:
		space += 1
pr = 1
mod = 998244353
for el in t:
	pr *= el
	pr %= mod
print(pr)


from sys import stdin
module = 998244353
(n, k) = map(int, stdin.readline().split())
P = list(map(int, stdin.readline().split()))
max_value = 0
for i in range(n, n - k, -1):
	max_value += i
index_list = []
for i in range(n):
	if P[i] >= n - k + 1:
		index_list.append(i)
result = 1
for i in range(k - 1):
	result *= index_list[i + 1] - index_list[i]
	result %= module
print(max_value, result)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	md = 998244353
	(n, k) = MI()
	aa = LI()
	b = n - k + 1
	s = 1
	cnt = -1
	for a in aa:
		if cnt > -1:
			cnt += 1
		if a >= b:
			if cnt > 0:
				s = s * cnt % md
			cnt = 0
	print(k * (2 * n - k + 1) // 2, s)
main()


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
arr = inlt()
n = arr[0]
k = arr[1]
perm = inlt()
a = k * (2 * n - k + 1) / 2
rra = []
j = 0
while j < n:
	if perm[j] > n - k:
		rra.append(j)
	j += 1
i = 0
b = 1
while i < k - 1:
	diff = rra[i + 1] - rra[i]
	b *= diff
	b = b % 998244353
	i += 1
print(int(a), b)


concac = list(map(int, input().split()))
n = concac[0]
k = concac[1]
a = list(map(int, input().split()))
b = []
c = []
sum = 0
for i in range(0, n):
	b.append((a[i], i))
b.sort()
for i in range(n - k, n):
	c.append(b[i][1])
	sum += b[i][0]
c.sort()
mul = 1
mod = 998244353
for i in range(1, len(c)):
	mul *= c[i] - c[i - 1]
	mul %= mod
print(sum, mul)


from sys import stdin
from collections import defaultdict, Counter
from math import gcd
(n, k) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
ans = 0
for i in range(k):
	ans += n - i
prev = -1
a = []
for i in range(n):
	curr = arr[i]
	if n - k < curr:
		a.append(i)
num = 1
for i in range(k - 1):
	num *= a[i + 1] - a[i]
print(ans, num % 998244353)


R = lambda : map(int, input().split())
(n, k) = R()
a = [i for (i, x) in enumerate(R()) if x > n - k]
r = 1
for (i, j) in zip(a, a[1:]):
	r = r * (j - i) % 998244353
print(n * k - k * (k - 1) // 2, r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
p = n - k + 1
q = n
for i in range(n):
	if a[i] <= q and a[i] >= p:
		b.append(i + 1)
c = []
for i in range(len(b) - 1):
	c.append(b[i + 1] - b[i])
pr = 998244353
cn = 1
for i in c:
	cn = cn % pr * (i % pr) % pr
sn = 0
for i in range(p, q + 1):
	sn += i
print(sn, cn)


(n, k) = map(int, input().split())
p = [int(x) for x in input().split()]
count = 0
num = 1
z = 998244353
j = 0
ans = (n * (n + 1) - (n - k) * (n - k + 1)) // 2
for i in range(n):
	if count == k:
		break
	if p[i] > n - k:
		count += 1
		if count > 1:
			num = num * (i - j) % z
		j = i
print(ans, num)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
v = list(zip(lst, range(n)))
v = sorted(v, key=lambda x: x[0], reverse=True)
sol = 1
m_sol = sum([x[0] for x in v[:k]])
maxims = sorted([m[1] for m in v[:k]])
for i in range(1, k):
	dif = maxims[i] - maxims[i - 1]
	sol = sol * dif
	sol %= 998244353
print('{} {}'.format(m_sol, sol))


import sys
import math
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, k) = invr()
a = inara()
shuru = n - k + 1
maxi = 0
for i in range(shuru, n + 1):
	maxi += i
indx = []
for i in range(n):
	if a[i] >= shuru:
		indx.append(i)
total = 1
for i in range(1, len(indx)):
	diff = indx[i] - indx[i - 1]
	total *= diff
	total %= 998244353
print(maxi, total)


p = 998244353
(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
drr = []
for i in range(n):
	if arr[i] >= n - k + 1:
		drr.append(i)
total = int(k * ((n + n - k + 1) / 2))
total2 = 1
for i in range(1, len(drr)):
	total2 *= drr[i] - drr[i - 1]
	total2 = total2 % p
print(total, total2)


(n, k) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
print(n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2, end=' ')
i = n
g = 1
f = -1
if n != k:
	for i in range(0, n):
		if f != -1 and n - k < a[i]:
			g = g * (i + 1 - p)
			g = g % 998244353
			p = i + 1
		elif n - k < a[i]:
			f = 0
			p = i + 1
	print(g)
else:
	print(1)


def answer(n, k, arr):
	maxValue = 0
	partitionCount = 1
	maxIndexArr = []
	for i in range(0, n):
		if arr[i] >= n - k + 1:
			maxIndexArr.append(i)
			maxValue += arr[i]
	for i in range(1, len(maxIndexArr)):
		partitionCount *= maxIndexArr[i] - maxIndexArr[i - 1]
	return str(maxValue) + ' ' + str(partitionCount % 998244353)
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
print(answer(n, k, arr))


(n, k) = map(int, input().split())
num = map(int, input().split())
rta = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
indices = []
for (idx, val) in enumerate(num):
	if val > n - k:
		indices.append(idx)
acu = 1
for (idx, val) in enumerate(indices):
	if idx == 0:
		continue
	acu = acu * (val - indices[idx - 1]) % 998244353
print('{} {}'.format(rta, acu))


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
v = [i for (i, v) in enumerate(p) if v > n - k]
MOD = 998244353
r = 1
for i in range(k - 1):
	r = r * (v[i + 1] - v[i]) % MOD
print((n - k + 1 + n) * k // 2, r)


import sys
(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
ans1 = (n + n - k + 1) * k // 2
ans2 = 0
niz = n - k + 1
masr = []
for i in range(len(lst)):
	if lst[i] >= niz:
		sm = 0
		for j in range(i, len(lst)):
			sm += 1
			if lst[j] >= niz:
				masr.append(sm)
				sm = 0
		ans2 = 1
		for j in masr:
			ans2 *= j
		print(ans1, ans2 % 998244353)
		sys.exit()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = []
for i in range(n):
	x.append((l[i], i))
x.sort(key=lambda x: x[0])
s = 0
c = 0
z = []
for i in range(n - 1, -1, -1):
	c += 1
	s += x[i][0]
	z.append(x[i][1])
	if c == m:
		break
z.sort()
p = 1
for i in range(1, len(z)):
	p *= z[i] - z[i - 1]
print(s, p % 998244353)


import os
import sys
from io import BytesIO, IOBase
from math import log, floor, ceil
mod = 998244353

def main():
	(n, k) = map(int, input().split())
	a = list(enumerate(map(int, input().split())))
	a.sort(key=lambda x: x[1], reverse=True)
	ak = a[:k]
	(mval, mc) = (0, 0)
	ak.sort(key=lambda x: x[0])
	mc = 1
	for x in ak:
		mval += x[1]
	for i in range(0, len(ak) - 1):
		mc = mc % mod * ((ak[i + 1][0] - ak[i][0]) % mod) % mod
	print(mval, mc % mod)
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')
main()


import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, k) = rinput()
a = rlinput()
d = defaultdict(int)
sa = sorted(a, reverse=True)
ans1 = 0
for i in range(k):
	ans1 += sa[i]
	d[sa[i]] = 1
prev = 0
count = 0
ans2 = 1
for i in range(n):
	if a[i] in d:
		if count != 0:
			ans2 = ans2 * (i - prev) % 998244353
		prev = i
		count += 1
print(ans1, ans2)


(n, ab) = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
d = l[:]
c = []
k = n - ab
sum1 = n * (n + 1) // 2
sum2 = k * (k + 1) // 2
sum3 = sum1 - sum2
d = {}
for i in range(len(l)):
	d[l[i]] = i
fin = sum3
print(fin, end=' ')
d = []
d.append(0)
for i in range(n):
	if l[i] > k:
		d.append(i)
j = d[0]
for i in d[1:]:
	c.append(i - j)
	j = i
mul = 1
c = c[1:]
for i in c:
	mul = mul * i
print(mul % 998244353)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
mi = n - k + 1
for i in range(n, n - k, -1):
	s += i
count = 1
kk = 0
ans = 1
for i in range(n):
	if a[i] >= mi:
		kk = i
		break
for i in range(kk + 1, n):
	if a[i] >= mi:
		ans *= count
		ans %= 998244353
		count = 1
	else:
		count += 1
		count %= 988244353
print(s, ans)


(n, k) = (int(i) for i in input().split())
p_arr = [int(i) for i in input().split()]
mod = 998244353
ans = 1
cur = 1
s = 0
first = True
for p in p_arr:
	if p > n - k:
		ans *= cur
		ans %= mod
		s += p
		cur = 1
		first = False
	else:
		cur += not first
print(s, ans)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
mod = 998244353
(n, k) = mapi()
a = list(mapi())
ans = 0
res = 1
last = 0
flag = False
for i in range(n):
	if a[i] >= n - k + 1:
		ans += a[i]
		if flag:
			res = res * (i - last) % mod
		flag = True
		last = i
print(ans, res)


li = list(map(int, input().split()))
n = li[0]
k = li[1]
p = list(map(int, input().split()))
p_copy = p.copy()
max_value = 0
arr = []
nop = 1
for i in range(len(p)):
	if p[i] >= n - k + 1:
		max_value += p[i]
		arr.append(i)
for i in range(len(arr)):
	if i != len(arr) - 1:
		nop *= arr[i + 1] - arr[i]
		nop %= 998244353
print(max_value, nop)


from sys import stdin, stdout
input = stdin.readline
MOD = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
d = {}
for i in range(n):
	d[p[i]] = i
l = [0] * k
s = 0
for i in range(n, n - k, -1):
	s += i
	l[n - i] = d[i]
l.sort()
f = 1
for i in range(1, k):
	f *= l[i] - l[i - 1]
	f %= MOD
stdout.write(f'{s} {f}')


a = input().split()
b = list(map(int, input().split()))
n = int(a[0])
k = int(a[1])
l = []
ans = 1
c = 1
f = 0
flag = 0
s = 0
for i in b:
	if i >= n - k + 1:
		ans = ans * (c - f) % 998244353
		f = c
		s = s + i
		if flag == 0:
			ans = ans / c
			flag = 1
	c = c + 1
ans = ans % 998244353
print(str(s) + ' ' + str(int(ans)))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
ak = [0] * k
s = 0
for (idx, value) in enumerate(a):
	if n - value < k:
		s += value
		ak[n - value] = idx + 1
ak = sorted(ak)
res = 1
for i in range(1, len(ak)):
	res = (ak[i] - ak[i - 1]) * res % 998244353
print(s, res)


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
l = []
s = set(range(n - k + 1, n + 1))
for i in range(n):
	if lis[i] in s:
		l.append(i)
p = 1
mod = 998244353
for i in range(1, k):
	p = p * (l[i] - l[i - 1]) % mod
print(sum(s), p)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ans = sum(range(n - k + 1, n + 1))
an = 1
pos = []
g = set(range(n - k + 1, n + 1))
for i in range(n):
	if p[i] in g:
		pos.append(i)
pos.sort()
for i in range(1, k):
	an = an * (pos[i] - pos[i - 1]) % 998244353
print(ans, an)


from sys import stdin
input = stdin.readline
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
tot = n * k - k * (k - 1) // 2
prev = 0
mult = 1
mod = 998244353
for i in range(len(p)):
	if p[i] > n - k:
		prev = i
		break
for i in range(i + 1, len(p)):
	if p[i] > n - k:
		mult *= i - prev
		prev = i
		mult %= mod
print(str(tot) + ' ' + str(mult))


(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
a = sorted(lis, reverse=True)
ans = sum(a[:m])
aa = sorted(range(len(lis)), key=lambda k: lis[k], reverse=True)[:m]
aa.sort()
p = 1
for i in range(m - 1):
	p *= aa[i + 1] - aa[i]
print(ans, p % 998244353)


import sys

class CPermutationPartitions:

	def solve(self):
		MOD = 998244353
		(n, k) = [int(_) for _ in input().split()]
		p = [int(_) for _ in input().split()]
		cnt = 0
		indices = []
		for i in range(n):
			if p[i] >= n - (k - 1):
				indices.append(i)
		cnt = 1
		for i in range(k - 1):
			cnt = cnt * (indices[i + 1] - indices[i]) % MOD
		print(n * k - k * (k - 1) // 2, cnt)
solver = CPermutationPartitions()
input = sys.stdin.readline
solver.solve()


(n, k) = map(int, input().split())
li = [int(x) for x in input().split()]
ans = 0
ans2 = 1
re = []
for i in range(n):
	if li[i] > n - k:
		re.append(i)
		ans += li[i]
for i in range(k - 1):
	ans2 = ans2 * (re[i + 1] - re[i])
print(ans, ans2 % 998244353)


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

def in1():
	return int(input())

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

def inx():
	return [int(_) for _ in input().split()]
(n, k) = in3()
p = inx()
total = 1
pre = -1
for (i, it) in enumerate(p):
	if it > n - k:
		if pre > -1:
			total = total * (i - pre) % MOD
		pre = i
print(sum([x for x in range(n - k + 1, n + 1)]), total)


(n, k) = input().split()
n = int(n)
k = int(k)
l = list(map(int, input().split()))
d = {}
for i in range(0, len(l)):
	d[l[i]] = i
l.sort()
l.reverse()
sum1 = sum(l[0:k])
c = []
for i in range(0, k):
	c.append(d[l[i]])
c.sort()
f = 1
for i in range(1, len(c)):
	f = f * (c[i] - c[i - 1])
	f = f % 998244353
print(sum1, f)


MOD = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
print(k * (2 * n - k + 1) // 2, end=' ')
post = []
for i in range(len(p)):
	if n - k + 1 <= p[i] <= n:
		post.append(i)
ans = 1
for i in range(len(post) - 1):
	ans = ans * (post[i + 1] - post[i]) % MOD
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
p = sorted(arr)
d = {}
ans1 = 0
for i in range(n - 1, n - k - 1, -1):
	d[p[i]] = 1
	ans1 += p[i]
cx = 0
found = False
ans2 = 1
for i in range(n):
	if arr[i] in d and (not found):
		cx = i
		found = True
		continue
	elif arr[i] in d:
		ans2 *= i - cx
		ans2 %= 998244353
		cx = i
print(ans1, ans2 % 998244353)


import string
import math
import collections

def main():
	(n, m) = map(int, input().split())
	tab = list(map(int, input().split()))
	t2 = []
	s = 0
	for x in range(n):
		if tab[x] >= n - m + 1:
			t2.append(x)
			s += tab[x]
	t2.sort()
	inc = 1
	for x in range(1, len(t2)):
		inc *= t2[x] - t2[x - 1]
		inc %= 998244353
	print(s, inc)
main()


import sys
(n, k) = [int(v) for v in sys.stdin.readline().split()]
aq = [int(v) for v in sys.stdin.readline().split()]
b = n - k
s = 0
c = 1
li = None
for (i, a) in enumerate(aq):
	if a > b:
		s += a
		if li is not None:
			c *= i - li
			c %= 998244353
		li = i
print('%d %d' % (s, c))


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
ls = []
for i in range(n):
	if p[i] > n - k:
		ans += p[i]
		ls.append(i)
total = 1
M = 998244353
for i in range(1, len(ls)):
	total *= ls[i] - ls[i - 1]
	total %= M
print(ans, total)


(n, k) = list(map(int, input().split()))
ls = list(map(int, input().split()))
answer = 0
count = 1
stack = []
for i in range(n):
	if ls[i] >= n - k + 1:
		if stack:
			count *= i - stack[-1]
		stack.append(i)
		answer += ls[i]
print(answer, count % 998244353)


(n, k) = map(int, input().split())
ls = [int(k) for k in input().split()]
a = k * (2 * n - k + 1) // 2
ans = 1
p = -1
for i in range(n):
	if ls[i] > n - k:
		if p == -1:
			p = i
		else:
			ans *= i - p
			p = i
print(str(a) + ' ' + str(ans % 998244353))


import sys
ip = lambda : sys.stdin.readline()
split = lambda : ip().split(' ')
ip1 = lambda : map(int, split())
arr = lambda : list(ip1())
mod = 998244353
(n, k) = ip1()
a = arr()
b = sorted(a)
c = b[-k:]
ans = sum(c)
d = {i: -1 for i in c}
for i in range(n):
	if a[i] in d:
		d[a[i]] = i
e = sorted(d.values())
ans1 = 1
for i in range(len(e) - 1):
	v = e[i + 1] - e[i]
	ans1 = ans1 * v
print(ans, ans1 % mod)


(t, n) = map(int, input().split())
arr = [int(i) for i in input().split()]
brr = [0 for i in range(n)]
j = 0
for i in range(t):
	if arr[i] <= t and arr[i] > t - n:
		brr[j] = i
		j += 1
final = 0
distance = 1
mod = 998244353
for i in range(n):
	final = final + (t - i)
for i in range(1, n):
	distance = distance * (brr[i] - brr[i - 1])
	distance = distance % mod
print(final, distance, end=' ')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
(n, k) = li()
l = li()
l1 = []
s = set()
curr = n
while k:
	s.add(curr)
	k -= 1
	curr -= 1
curr = 0
for i in range(n):
	if l[i] not in s:
		curr += 1
	else:
		l1.append(curr)
		curr = 0
l1 = l1[1:]
ans = 1
for i in range(len(l1)):
	if l1[i]:
		ans = ans * (l1[i] + 1) % mod
print(sum(list(s)), ans % mod)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
p = 1
c = n - k + 1
d = 0
sum = 0
for i in range(len(b)):
	if b[i] >= c and d == 0:
		sum += b[i]
		q = i
		d = 1
	elif b[i] >= c and d == 1:
		sum += b[i]
		p = p * (i - q) % 998244353
		q = i
print(sum, p % 998244353)


(n, k) = [int(p) for p in input().split()]
arr = [int(p) for p in input().split()]
count = 0
ans = 1
total = -1
for i in range(len(arr)):
	if arr[i] >= n - k + 1:
		count += arr[i]
		if total != -1:
			ans = ans * (i - total) % 998244353
		total = i
print(count, ans)


(x, y) = map(int, input().split())
lt = list(map(int, input().split()))
a = 0
mt = 0
an = 1
ct = 0
for i in range(x):
	if lt[i] > x - y and ct != 0:
		a += lt[i]
		an *= i - mt
		mt = i
	elif lt[i] > x - y and ct == 0:
		a += lt[i]
		ct = 1
		mt = i
print('%d %d' % (a, an % 998244353))


import heapq
MOD = 998244353
[n, k] = (int(x) for x in input().split(' '))
p = [int(x) for x in input().split(' ')]
heapsize = 0
heap = []
i = 0
for p_cur in p:
	heapq.heappush(heap, (p_cur, i))
	i = i + 1
klargest = heapq.nlargest(k, heap)
maxval = sum([val for (val, ind) in klargest])
kindices = [ind for (val, ind) in klargest]
kindices.sort()
is_first = True
c = 1
prev = 0
for ind in kindices:
	if is_first:
		prev = ind
		is_first = False
	else:
		c = c * (ind - prev) % MOD
		prev = ind
print(maxval, c)


from collections import defaultdict as dc
from collections import deque as dq
from bisect import bisect_left, bisect_right, insort_left
import sys
import math
from heapq import heapify, heappush, heappop

def rem(p, q):
	z = p // q
	r = p - q * z
	return r

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

def line():
	p = list(map(int, input().split()))
	return p
t = 1
mod = 998244353
for i in range(1):
	(n, k) = line()
	a = line()
	p = dc(int)
	q = sorted(a, reverse=True)
	s = 0
	for i in range(k):
		s = s + q[i]
		p[q[i]] += 1
	ans = 1
	c = 0
	l = 0
	for i in range(n):
		if p[a[i]] > 0:
			if l == 1:
				ans = ans % mod * (i - c + 1) % mod % mod
			l = 1
			c = i + 1
			p[a[i]] -= 1
	print(s, ans)


import collections as cc
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
h = l.copy()
h.sort(reverse=True)
ans = sum(h[:k])
temp = dict(cc.Counter(h[:k]))
te = []
for i in range(n):
	if temp.get(l[i], 0):
		temp[l[i]] -= 1
		te.append(i)
an = 1
for i in range(len(te) - 1):
	an *= abs(te[i] - te[i + 1])
print(ans, an % 998244353)


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
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	mod = 998244353
	for _ in range(1):
		(n, k) = ria()
		a = ria()
		z = 1
		for i in range(n):
			if a[i] > n - k:
				prevptr = i
				break
		c = 1
		for i in range(prevptr, n):
			if a[i] > n - k:
				z *= c % mod
				c = 1
			else:
				c += 1
		e = n - k
		f = n * (n + 1) // 2 - e * (e + 1) // 2
		wia([f, z % mod])
	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()


def solve():
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	max_idx = []
	for (i, p_i) in enumerate(p):
		if p_i > n - k:
			max_idx.append(i)
	res = 1
	for i in range(1, k):
		res *= max_idx[i] - max_idx[i - 1]
		res = res % 998244353
	p_value = int((n - k + 1 + n) * k / 2)
	print(p_value, res)

def main():
	solve()
main()


def linput(a):
	return [int(i) for i in a.split()]
for ughblnk in range(1):
	(n, k) = linput(input())
	q = linput(input())
	su = (n + (n - k + 1)) * k // 2
	nk = n - k + 1
	i = 0
	while q[i] < nk:
		i += 1
	ii = i
	s = 1
	for j in range(i + 1, n):
		if q[j] >= nk:
			s *= j - ii
			ii = j
			s = s % 998244353
	print(su, s)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
m = 998244353
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = mapin()
b = [int(x) for x in input().split()]
l = [0] * n
ll = []
for i in range(n):
	l[b[i] - 1] = i
ann = 0
for i in range(k):
	ann += n - i
	ll.append(l[n - i - 1])
ll.sort()
temp = ll[0] - 1
ans = 1
for i in ll:
	aa = i - temp
	ans = ans * aa
	ans %= m
	temp = i
print(ann, ans % m)


import sys
import math
from collections import deque

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
(n, k) = read_int_line()
a = read_int_line()
ind = []
for i in range(n):
	if n - k + 1 <= a[i] <= n:
		ind.append(i)
s = 0
for i in ind:
	s += a[i]
count = 1
p = 998244353
for i in range(1, len(ind)):
	count = count % p * (ind[i] - ind[i - 1]) % p % p
print(s, count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
st = set(sorted(a)[n - k:])
sm = sum(st)
mod = 998244353
lst = []
for i in range(n):
	if a[i] in st:
		lst.append(i)
x = 1
for i in range(1, k):
	x *= lst[i] - lst[i - 1]
	x %= mod
print(sm, x)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
diff = n - k
high = n * (n + 1) // 2 - diff * (diff + 1) // 2
prev = -1
ways = 1
for i in range(n):
	if p[i] > diff:
		if prev != -1:
			ways = ways * (i - prev)
		prev = i
print(high, ways % 998244353)


from collections import defaultdict
M = 998244353
(n, k) = map(int, input().split())
List = [int(x) for x in input().split()]
Dict = defaultdict(int)
for i in range(n):
	Dict[List[i]] = i + 1
Ans = 1
Sorted = []
for i in range(k):
	Sorted.append((Dict[n - i], n - i))
Sorted.sort()
Sum = Sorted[0][1]
for i in range(1, k):
	Ans *= Sorted[i][0] - Sorted[i - 1][0]
	Sum += Sorted[i][1]
	Ans %= M
print(Sum, Ans)


(n, k) = map(int, input().split())
(a, ans, mod) = (list(map(int, input().split())), 1, 998244353)
(ma, tem) = (set(), 0)
for i in range(n, n - k, -1):
	ma.add(i)
ans1 = sum(list(ma))
for i in range(n):
	if a[i] in ma:
		ma.discard(a[i])
		if len(ma) < k - 1:
			ans = ans % mod * tem % mod % mod
		tem = 0
	tem += 1
print(ans1, ans)


def main():
	(n, k) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	min_value = n - k + 1
	index = 0
	counter = 1
	first_result = (n + min_value) * k // 2
	second_result = 1
	while p[index] < min_value:
		index += 1
	for item in p[index + 1:]:
		if item >= min_value:
			second_result *= counter
			second_result %= 998244353
			counter = 1
		else:
			counter += 1
	print(first_result, second_result)
main()


(n, k) = map(int, input().split())
p = [int(i) for i in input().split()]
modulo = 998244353
max_value = sum(range(n - k + 1, n + 1))
num_of_partitions = 1
diff = 1
flag = 0
for num in p:
	if num > n - k:
		if flag == 1:
			num_of_partitions = num_of_partitions * diff % modulo
			num_of_partitions = 1 if num_of_partitions == 0 else num_of_partitions
		else:
			flag = 1
		diff = 1
	else:
		diff += 1
print(max_value, num_of_partitions)


(n, k) = [int(x) for x in input().split()]
max_val = 0
num_ways_nobar = 0
num_ways_bar = 1
pr = 998244353
ps = [int(x) for x in input().split()]
for (i, p) in enumerate(ps):
	if p + k > n:
		max_val += p
		num_ways_nobar = num_ways_bar
	else:
		num_ways_bar = (num_ways_bar + num_ways_nobar) % pr
print(max_val, num_ways_nobar)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = k * n - k * (k - 1) // 2
count = 1
for i in range(n):
	if l[i] > n - k:
		break
j = i
p = j
for i in range(p + 1, n):
	if l[i] > n - k:
		count = count * (i - j) % 998244353
		j = i
print(s, count % 998244353)


(n, k) = list(map(int, input().split()))
array = list(map(int, input().split()))
this = array.copy()
for i in range(n):
	this[i] = (array[i], i)
this = sorted(this, reverse=True)
ans1 = 0
indexes = []
for i in range(k):
	ans1 += this[i][0]
	indexes.append(this[i][1])
indexes.sort()
ans2 = 1
for i in range(k - 1):
	this = indexes[i + 1] - indexes[i]
	ans2 = ans2 * this
print(*(ans1, ans2 % 998244353))


(n, s) = map(int, input().split())
m = 998244353
greatest = [0] * (n + 1)
lis = list(map(int, input().split()))
lis2 = lis.copy()
indexOf = [0] * (n + 1)
for i in range(len(lis2)):
	indexOf[lis2[i]] = i
lis.sort()
index = [0] * (n + 1)
for i in range(n - s, n):
	index[lis[i]] = 1
ans = []
for i in lis2:
	if index[i] == 1:
		ans.append(indexOf[i])
diff = 1
for i in range(1, len(ans)):
	diff = diff * (ans[i] - ans[i - 1]) % m
print(sum(lis[n - s:n + 1]), diff % m)


from sys import stdin, stdout
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as cmb, permutations as pmb
from math import factorial as f, ceil, gcd, sqrt, log, inf
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)
MOD = 998244353

def soe(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def ncr(n, r):
	(p, k) = (1, 1)
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			(p, k) = (p * n, k * r)
			m = gcd(p, k)
			(p, k) = (p // m, k // m)
			(n, r) = (n - 1, r - 1)
	else:
		p = 1
	return p

def solve():
	(n, k) = mi()
	arr = li()
	p = sorted(arr)
	d = {}
	ans1 = 0
	for x in range(n - 1, n - k - 1, -1):
		d[p[x]] = 1
		ans1 += p[x]
	cx = 0
	found = False
	ans2 = 1
	for x in range(n):
		if arr[x] in d and (not found):
			cx = x
			found = True
			continue
		elif arr[x] in d:
			ans2 *= x - cx
			ans2 %= MOD
			cx = x
	print(ans1, ans2 % MOD)
for _ in range(1):
	solve()


import sys
input = sys.stdin.readline
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
SI = lambda : input().strip('\n')
II = lambda : int(input())
(n, k) = MI()
one = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
s = n - k + 1
(two, m) = (1, 998244353)
p = 0
for (i, v) in enumerate(MI(), 1):
	if not p and v >= s:
		p = i
	elif v >= s:
		c = i
		two = two * (c - p) % m
		p = c
print(one, two)


import sys

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

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

def get_string():
	return sys.stdin.readline().strip()
(n, k) = map(int, input().split())
mod = 998244353
arr = get_array()
s = 0
for i in range(n - k + 1, n + 1):
	s += i
iarr = []
for i in range(n):
	if arr[i] >= n - k + 1:
		iarr.append(i)
no = 1
for i in range(1, len(iarr)):
	no = no % mod * (iarr[i] - iarr[i - 1]) % mod
print(s, no)


P = [int(x) for x in input().split(' ')]
n = P[0]
k = P[1]
l = [int(x) for x in input().split(' ')]
s = int(k * (2 * n - k + 1) / 2)
c = 0
arr = []
for i in range(n):
	if l[i] <= n - k:
		c += 1
	else:
		arr.append(c)
		c = 0
arr[0] = 0
pro = 1
for i in arr:
	pro *= i + 1
	pro %= 998244353
print(s, pro)


parameters = list(map(int, input().split()))
p = list(map(int, input().split()))
important = []
maxSum = 0
for i1 in range(len(p)):
	if p[i1] > parameters[0] - parameters[1]:
		important.append(i1)
		maxSum += p[i1]
important.sort()
result = 1
for i1 in range(0, len(important) - 1, 1):
	result *= important[i1 + 1] - important[i1]
	result = result % 998244353
print(maxSum, result)


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 998244353

def ddprint(x):
	if DBG:
		print(x)
(n, k) = inm()
p = inl()
sm = (2 * n - k + 1) * k // 2
a = -1
x = 1
for i in range(n):
	if p[i] > n - k:
		if a >= 0:
			x = x * (i - a) % R
		a = i
print('{} {}'.format(sm, x))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
m = 998244353
ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
f = 0
ans = 1
for i in range(n):
	if f == 0:
		if a[i] > n - k:
			f = 1
			j = i
	elif f == 1:
		if a[i] > n - k:
			ans = ans * (i - j) % m
			j = i
print(ans1, ans)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
s = (2 * n - k + 1) * k // 2
c = 0
res = 1
judge = False
for i in range(n):
	if a[i] >= n - k + 1:
		res = res * (c + 1) % mod
		c = 0
		judge = True
	elif judge:
		c += 1
print(s, res)


import math as m
[n, k] = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
a = 0
b = 0
filled = False
thresh = n - k + 1
prod = 1
for i in range(n):
	if arr[i] >= thresh:
		if filled:
			(a, b) = (i, a)
			prod = prod * (a - b) % 998244353
		else:
			a = i
			filled = True
p2 = (n + thresh) * (n - thresh + 1) // 2
print(p2, prod)


def main():
	mod = 998244353
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	val = 0
	vals = set()
	for i in range(n, n - k, -1):
		val += i
		vals.add(i)
	ways = 1
	prev = -1
	for i in range(n):
		if arr[i] in vals:
			if prev != -1:
				ways *= i - prev
			ways %= mod
			prev = i
	print(val, ways)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(b, c, ans, res, mod) = (sorted(a), [], 1, -1, 998244353)
for i in range(n):
	if a[i] > n - k:
		if res > -1:
			ans = ans * (i - res)
			ans = ans % mod
		res = i
print((n - k + 1 + n) * k // 2, ans)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
d = [int(x) for x in input().split(' ')]
c = []
s = 0
for i in range(n):
	if d[i] > n - k:
		c.append(i)
		s += d[i]
f = 1
for j in range(1, k):
	f *= c[j] - c[j - 1]
	f %= 998244353
print(s, f)


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

def case():
	(n, k) = li()
	a = li()
	s = 1
	ans = 0
	p = n
	d = defaultdict(int)
	for i in range(n):
		d[a[i]] = i
	a.sort(reverse=True)
	b = []
	for i in range(k):
		b.append(d[a[i]])
	b.sort()
	for i in range(0, len(b) - 1):
		s *= b[i + 1] - b[i]
		s = s % 998244353
	for i in range(k):
		ans += p
		p -= 1
	print(ans, s)
for _ in range(1):
	case()


from math import *
mod = 998244353
(n, k) = map(int, input().split())
p = [int(i) for i in input().split()]
ind = {}
for i in range(n):
	ind[p[i]] = i
bk = list(sorted(ind.keys(), reverse=True))[:k]
print(sum(bk), end=' ')
inds = []
for k in bk:
	inds.append(ind[k])
inds.sort()
ans = 1
for i in range(1, len(inds)):
	ans = ans * (inds[i] - inds[i - 1]) % mod
print(ans)


import sys

def mmul(a, b, m):
	return a % m * (b % m) % m
[n, k] = [int(i) for i in sys.stdin.readline().split()]
p = [int(j) for j in sys.stdin.readline().split()]
a = []
val = n
ans = 0
for i in range(k):
	ans += val
	val -= 1
m = 998244353
check = n - (k - 1)
ways = 1
ctr = -2
for g in range(n):
	if p[g] >= check:
		if ctr < 0:
			ctr = 1
		else:
			ways = mmul(ways, ctr, m)
			ctr = 1
	elif ctr > 0:
		ctr += 1
print(ans, ways)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
fans = 1
sum = 0
ind = []
for i in range(n):
	if a[i] > n - k:
		ind.append(i)
		sum += a[i]
for i in range(len(ind) - 1):
	fans = fans * (ind[i + 1] - ind[i]) % mod
print(sum, fans)


import math, collections, sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
val = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
need = [0 for i in range(n)]
for i in range(n):
	if a[i] > n - k:
		need[i] = 1
gaps = [0]
for i in range(n):
	if need[i]:
		gaps.append(0)
	else:
		gaps[-1] += 1
ans = 1
mod = 998244353
for i in range(1, len(gaps) - 1):
	ans *= gaps[i] + 1
	ans %= mod
print(val, ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
num_partitions = 1
cutoff = len(arr) - (k - 1)
max_value = (cutoff + len(arr)) * k / 2
found_first_max = False
for (index, val) in enumerate(arr):
	if val >= cutoff:
		if not found_first_max:
			found_first_max = True
			last_big_index = index - 1
		diff = index - last_big_index
		num_partitions = num_partitions * diff % 998244353
		last_big_index = index
print(int(max_value), num_partitions)


(n, k) = tuple(map(int, input().split()))
p = list(map(int, input().split()))
indicies = list(range(n))
indicies.sort(key=lambda i: p[i], reverse=True)
top_k_indicies = sorted(indicies[:k])
result = 1
for (v1, v2) in zip(top_k_indicies[:-1], top_k_indicies[1:]):
	result *= v2 - v1
	result = result % 998244353
print(sum((p[i] for i in top_k_indicies)), result)


pos = []
(n, k) = map(int, input().split())
mod = 998244353
ans1 = 1
ans2 = 1
xl = input().split()
for i in range(1, n + 1):
	x = int(xl[i - 1])
	if x + k > n:
		pos.append(i)
for i in range(k):
	ans1 = ans1 + (n - i)
for i in range(1, len(pos)):
	ans2 = ans2 * (pos[i] - pos[i - 1]) % mod
print('{} {}'.format(ans1 - 1, ans2))


li1 = [int(x) for x in input().split()]
li2 = [int(x) for x in input().split()]
(n, k) = (li1[0], li1[1])
(max_possible, last, product) = (0, 0, 1)
count = 0
for i in range(n):
	if li2[i] >= n - k + 1:
		max_possible += li2[i]
		if count == 0:
			count += 1
			last = i
		elif count == 1:
			product = product * (i - last)
			last = i
print(max_possible, product % 998244353)


from copy import deepcopy
mod = 998244353
[n, k] = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
bak = deepcopy(p)
bak.sort(reverse=True)
visited = set(bak[:k])
cnt = []
j = 1
for i in range(n):
	if p[i] in visited:
		j = i
		break
for i in range(j + 1, n):
	if p[i] in visited:
		cnt.append(i - j)
		j = i
prod = 1
mv = 0
for x in cnt:
	prod *= x
for i in range(k):
	mv += bak[i]
print(mv, prod % mod)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
s = sorted(p, reverse=True)
sm = sum(s[:k])
s = s[:k]
a = []
c = 0
pr = 1
for i in range(n):
	if p[i] > n - k:
		a.append(i)
		c = c + 1
	if c == k:
		break
for i in range(1, len(a)):
	pr *= a[i] - a[i - 1]
print(sm, pr % 998244353)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans1 = k * (n - k + 1 + n) // 2
gd = {}
for i in range(n - k + 1, n + 1):
	gd[i] = 1
ans = 1
cur = 1
ok = False
for i in range(n):
	if a[i] in gd:
		ok = True
		ans *= cur
		cur = 0
	if ok:
		cur += 1
print(ans1, ans % 998244353)


(n, k) = map(int, input().split())
A = [0] + [int(x) for x in input().split()]
B = [-1] * (n + 1)
for i in range(n + 1):
	B[A[i]] = i
C = []
for i in range(n, n - k, -1):
	C.append(B[i])
C.sort()
Ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
Ans2 = 1
for i in range(1, len(C)):
	Ans2 *= C[i] - C[i - 1]
	Ans2 %= 998244353
print(Ans1, Ans2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(a)
b.sort(reverse=True)
x = 0
for _ in range(k):
	x += b[_]
print(x, end=' ')
c = []
d = []
for _ in range(len(a)):
	if a[_] > n - k:
		c.append(_ + 1)
for _ in range(1, len(c)):
	d.append(c[_] - c[_ - 1])
i = 1
for _ in range(len(d)):
	i = i * d[_] % 998244353
print(i % 998244353)


def I():
	return list(map(int, input().split()))
(n, k) = I()
p = I()
s = 0
num = 1
for i in range(k):
	s += n - i
f = False
nums = 1
i = 0
first = False
while i < n:
	if first:
		initial = i
		i += 1
		if i == n:
			first = False
			break
		while not p[i] >= n - k + 1:
			i += 1
			if i == n:
				first = False
				break
		if first:
			final = i
			nums *= final - initial
			nums %= 998244353
	else:
		if p[i] >= n - k + 1:
			first = True
			continue
		i += 1
print(s, nums)


T = 1
for t in range(1, T + 1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a, reverse=True)
	groups = set(b[:k])
	first = True
	count = 0
	numbers = []
	for i in range(n):
		if a[i] in groups:
			if first:
				first = False
			else:
				numbers.append(count + 1)
			count = 0
		else:
			count += 1
	ans = 1
	for num in numbers:
		ans = ans * (num % 998244353) % 998244353
	print(sum(groups), ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = []
ans = 0
for i in range(n):
	if arr[i] >= n - k + 1:
		arr1.append(i)
		ans += arr[i]
mp = 1
mod = 998244353
sz = len(arr1)
for i in range(sz - 1):
	mp *= arr1[i + 1] - arr1[i]
	mp %= mod
print(ans, mp)


(n, k) = [int(zax) for zax in input().split()]
l = [int(zax) for zax in input().split()]
q = []
ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
ans2 = 1
if k == 1:
	print(ans1, ans2)
else:
	for i in range(n):
		if l[i] >= n - k + 1:
			q.append(i)
	for i in range(k - 1):
		ans2 *= q[i + 1] - q[i]
		ans2 %= 998244353
	print(ans1, ans2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
value = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
ways = 1
mod = 998244353
m = n - k + 1
counted = []
for i in range(n):
	if a[i] >= m:
		counted.append(i)
for i in range(len(counted) - 1):
	ways *= counted[i + 1] - counted[i]
	ways %= mod
print(value, ways)


import math
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
res2 = 1
deff = 0
cnt = 1
res1 = math.floor((n - k + 1 + n) / 2 * k)
for i in range(n):
	if deff == 0 and a[i] >= n - (k - 1):
		deff = 1
	if deff == 1 and a[i] >= n - (k - 1):
		res2 *= cnt
		cnt = 1
	elif deff == 1:
		cnt += 1
print(res1, res2 % 998244353)


import sys
input = sys.stdin.readline

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

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

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

def getStr():
	return input().strip()
(n, k) = getVars()
a = getList()
pos = -1
res = 1
for i in range(n):
	if a[i] > n - k:
		if pos > -1:
			res = res * (i - pos)
			res = res % 998244353
		pos = i
print((n - k + 1 + n) * k // 2, res)


from sys import stdin
from collections import deque

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
mod = 998244353
(n, k) = mi()
a = li()
s = n * (n + 1) // 2
n -= k
s -= n * (n + 1) // 2
c = 1
pos = []
for i in range(n + k):
	if a[i] > n:
		pos.append(i)
for i in range(1, len(pos)):
	c *= pos[i] - pos[i - 1]
	if c > mod:
		c %= mod
print(s, c)


(n, k) = map(int, input().split())
perm = list(map(int, input().split()))
ans1 = k * (n + n - k + 1) / 2
ans1 = int(ans1)
perm = [(perm[i], i) for i in range(n)]
perm.sort(reverse=True)
ind = []
for i in range(k):
	ind.append(perm[i][1])
ind.sort()
ans2 = 1
for i in range(len(ind) - 1):
	ans2 *= ind[i + 1] - ind[i]
	ans2 %= 998244353
print(ans1, ans2)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
bp = [0] * (n + 1)
taken = []
for id in range(n):
	bp[p[id]] = id
(st, cnt, ans_sum) = (n, 0, 0)
while cnt < k:
	cnt += 1
	taken.append(bp[st])
	ans_sum += st
	st -= 1
taken.sort()
ans = 1
mod = 998244353
for _ in range(len(taken)):
	if _ == 0:
		continue
	ans = ans * (taken[_] - taken[_ - 1]) % mod
print('{} {}'.format(ans_sum, ans))


import sys
input = sys.stdin.readline
mod = 1000000007
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (n + 1)
for i in range(n):
	B[A[i]] = i
LAST = B[-k:]
LAST.sort()
ans = 1
for i in range(1, len(LAST)):
	ans *= LAST[i] - LAST[i - 1]
	ans %= 998244353
num = 0
for i in range(n - k + 1, n + 1):
	num += i
print(num, ans)


import sys
input = sys.stdin.readline
from math import *
mod = 998244353
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
if n == k:
	print(sum(a), 1)
else:
	b = sorted(a, reverse=True)
	d = {}
	for i in range(k):
		d[b[i]] = 1
	prev = -1
	c = 1
	for i in range(n):
		if a[i] in d:
			if prev != -1:
				c = c * (-prev + i)
				c = c % mod
			prev = i
	print(sum(b[:k]), c)


def main():
	import sys
	input = sys.stdin.readline
	(N, K) = map(int, input().split())
	P = list(map(int, input().split()))
	mod = 998244353
	ans1 = 0
	for i in range(K):
		ans1 += N - i
	idx = []
	for i in range(N):
		if P[i] >= N - K + 1:
			idx.append(i)
	ans2 = 1
	for i in range(K - 1):
		j1 = idx[i]
		j2 = idx[i + 1]
		ans2 = ans2 * (j2 - j1) % mod
	print(ans1, ans2)
main()


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def def_value():
	return 0

def def_inf():
	return inf

def atoi(s):
	return ord(s) - ord('a')

def inc(s, n=1):
	return chr((ord(s) - ord('a') + n) % 26 + ord('a'))

class XY:

	def __init__(self, x, y):
		self.x = x
		self.y = y

def rotate(a, b, c):
	ang = (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y)
	if ang == 0:
		return 0
	else:
		return ang / abs(ang)
(n, k) = mp()
p = lmp()
ans1 = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
ans2 = 1
cnt = 0
j = 0
for i in range(n):
	j = i
	if p[j] > n - k:
		break
for i in range(j + 1, n):
	if p[i] > n - k:
		ans2 = ans2 * (cnt + 1) % mod2
		cnt = 0
	else:
		cnt += 1
print(ans1, ans2)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
mod = 998244353
(n, k) = inputnums()
p = inputlist()
ans = 1
a = []
for i in range(n):
	if n - k + 1 <= p[i] <= n:
		a.append(i)
for i in range(1, len(a)):
	ans *= a[i] - a[i - 1]
	ans %= mod
print((n + n - k + 1) * k // 2, ans)


(_, K) = [int(x) for x in input().split()]
ls = [(int(x), n) for (n, x) in enumerate(input().split())]
ls = sorted(ls)[-K:]
ls = sorted(ls, key=lambda x: x[1])
s = sum([x[0] for x in ls])
mul = 1
for i in range(len(ls) - 1):
	mul *= ls[i + 1][1] - ls[i][1]
	mul = mul % 998244353
print(s, mul)


(N, K) = input().split()
N = int(N)
K = int(K)
P = input().split()
P1 = []
for i in range(N):
	P[i] = int(P[i])
indices = []
ans1 = 0
ans2 = 1
for j in range(N):
	if P[j] >= N - K + 1:
		indices.append(j + 1)
		ans1 = ans1 + P[j]
for j in range(K - 1):
	ans2 = ans2 * (indices[j + 1] - indices[j])
ans2 = ans2 % 998244353
print(ans1, ans2)


import sys
(n, k) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
temp = []
for i in range(n):
	temp.append((i + 1, arr[i]))
temp.sort(key=lambda x: -x[1])
while len(temp) > k:
	temp.pop()
temp.append((-1, -1))
temp.sort(key=lambda x: x[0])
ans = []
res = 0
mod = 998244353
for i in range(1, k):
	ans.append(temp[i + 1][0] - temp[i][0])
val = 1
for i in ans:
	val *= i
for i in range(1, k + 1):
	res += temp[i][1]
print(res, val % mod)


def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

class Mod:

	def __init__(self, m):
		self.m = m

	def add(self, a, b):
		return (a + b) % self.m

	def sub(self, a, b):
		return (a - b) % self.m

	def mul(self, a, b):
		return a % self.m * (b % self.m) % self.m

	def div(self, a, b):
		return self.mul(a, pow(b, self.m - 2, self.m))

	def pow(self, a, b):
		return pow(a, b, self.m)

def slv(N, K, A):
	M = Mod(998244353)
	ans = 0
	B = [(a, i) for (i, a) in enumerate(A)]
	B.sort()
	C = []
	D = []
	for _ in range(K):
		(a, i) = B.pop()
		C.append(i)
		D.append(a)
	C.sort()
	ans = 1
	for i in range(1, len(C)):
		l = C[i - 1]
		r = C[i]
		ans = M.mul(ans, r - l)
	return (sum(D), ans)

def main():
	(N, K) = read_int_n()
	A = read_int_n()
	print(*slv(N, K, A))
main()


push = lambda : map(int, input().split())
(n, k) = push()
a = list(push())
cnt = 0
sum = 0
num = 1
pre = -1
for i in range(n):
	if a[i] > n - k:
		sum += a[i]
		if pre != -1:
			num *= i - pre
		pre = i
print(sum, num % 998244353)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
ab = k * (2 * n - (k - 1)) // 2
vb = -1
ans = 1
ct = 0
for i in range(n):
	if arr[i] > n - k:
		if vb != -1:
			ans *= ct + 1
			ans %= 998244353
		else:
			vb = 0
		ct = 0
	else:
		ct += 1
print('%d %d' % (ab, ans))


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
mod = 998244353
ans = []
for i in range(n):
	if p[i] >= n - k + 1:
		ans.append(i)
x = (2 * n - k + 1) * k // 2
num = 1
for i in range(len(ans) - 1):
	num = num * (ans[i + 1] - ans[i]) % mod
print(x, num)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
mod = 998244353
(n, k) = list(map(int, input().split()))
array = list(map(int, input().split()))
loc = []
for i in range(n):
	if array[i] > n - k:
		loc.append(i)
m = len(loc)
res = 1
for i in range(1, m):
	diff = loc[i] - loc[i - 1]
	res = res * diff % mod
print(str((n + n - k + 1) * k // 2) + ' ' + str(res))


from functools import reduce

def solve():
	(n, k) = map(int, input().split())
	mod = 998244353
	array = list(map(int, input().split()))
	if n == k:
		print(sum(array), 1)
		return
	maxs = list(sorted(array, reverse=True))[:k]
	b = [x + 1 for x in range(n) if array[x] > n - k]
	res = [b[i] - b[i - 1] for i in range(1, len(b))]
	if k == 1:
		count = 1
	else:
		count = reduce(lambda x, y: x * y % mod, res)
	print(sum(maxs), count)
solve()


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = A[:]
B.sort()
MOD = 998244353
M = set(B[-k:])
ans = 1
i = 0
while A[i] not in M:
	i += 1
prv = i
for i in range(prv + 1, n):
	if A[i] in M:
		ans *= i - prv
		ans %= MOD
		prv = i
print(sum(B[-k:]), ans)


MOD = 998244353
(n, k) = map(int, input().split(' '))
y = list(map(int, input().split()))
if n == k:
	print(sum(y), 1)
else:
	d = {}
	t = 0
	arr = []
	for i in y:
		d[i] = t
		arr.append(i)
		t += 1
	arr = sorted(arr, reverse=True)
	i = 0
	s = sum(arr[:k])
	arr1 = []
	while i < k:
		arr1.append(d[arr[i]])
		i += 1
	arr1 = sorted(arr1)
	count = 1
	for i in range(1, len(arr1)):
		count = count * (arr1[i] - arr1[i - 1])
		count = count % MOD
	print(s, count % MOD)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
sums = 0
idxs = []
for (i, num) in enumerate(p):
	if num > n - k:
		sums += num
		idxs.append(i)
idxs.sort()
res = 1
for i in range(len(idxs) - 1):
	res *= idxs[i + 1] - idxs[i]
print(sums, res % 998244353)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(N):
	B.append([A[i], i + 1])
B.sort(reverse=True)
C = []
mv = 0
for i in range(K):
	mv = mv + B[i][0]
	C.append(B[i][1])
C.sort()
fc = 1
for i in range(1, len(C)):
	fc = fc * (C[i] - C[i - 1]) % 998244353
fc = fc % 998244353
print(mv, fc)


from bisect import bisect_right
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
x = 998244353
if k == n:
	print(sum(l), 1)
elif k == 1:
	print(max(l), 1)
else:
	s = 0
	ind = []
	for j in range(0, n):
		if l[j] > n - k:
			ind.append(j)
			s += l[j]
	u = 1
	ind.sort()
	for i in range(0, k - 1):
		u = u % x * (ind[i + 1] - ind[i]) % x
	print(s, u)


r = 998244353
(x, y) = map(int, input().split())
l = list(map(int, input().split()))
pt = l[:]
pt.sort(reverse=True)
d = dict()
for i in range(x):
	d[l[i]] = i
li = []
for i in range(x - y + 1, x + 1):
	li.append(d[i])
li.sort()
sumi = 0
for i in range(y):
	sumi += pt[i]
o = 1
li.sort()
if x > 2:
	for i in range(len(li) - 1):
		o = o * (li[i + 1] - li[i])
	print(sumi, o % r)
else:
	o = 1
	print(sumi, o)


(n, k) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
first_ans = k * (2 * n - k + 1) // 2
big_num = 998244353
prev_ind = -1
ans = 1
for i in range(n):
	if p[i] >= n - k + 1:
		if prev_ind >= 0:
			ans *= i - prev_ind
			ans %= big_num
			prev_ind = i
		else:
			prev_ind = i
print(first_ans, ans % big_num)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
v = (2 * n - k + 1) * k // 2
mod = 998244353
ans = 1
prev = -1
for i in range(n):
	if p[i] >= n - k + 1:
		if prev != -1:
			ans = ans * (i - prev) % mod
		prev = i
print(v, ans)


import sys
import heapq
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(n, k) = sp()
arr = l()
dup = sorted(arr, reverse=True)
dup = set(dup[:k])
index = []
for i in range(n):
	if arr[i] in dup:
		index.append(i)
answer = 1
for i in range(len(index) - 1):
	answer = answer * (index[i + 1] - index[i]) % mod2
out(str(sum(dup)) + ' ' + str(answer))


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x, i):
	l = i
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
a = n - m + 1
sm = m * (2 * a + (m - 1)) // 2
smm = n * (n + 1) // 2
ans = 1
t = 1
s = 0
for i in range(n):
	if n - m + 1 <= ar[i] <= n:
		if s == 1:
			ans *= t
		s = 1
		t = 1
	elif s == 1:
		t += 1
print(sm, ans % 998244353)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
(a, cnt, ans, MOD) = ([], 1, 0, 998244353)
for i in range(len(p)):
	if p[i] > n - k:
		a.append(i)
		ans += p[i]
for i in range(1, len(a)):
	cnt = cnt % MOD * (a[i] - a[i - 1]) % MOD % MOD
print(ans, cnt)


X = list(map(int, input().split()))
List = list(map(int, input().split()))
MyDict = {}
for i in range(X[0], X[0] - X[1], -1):
	MyDict[i] = 0
Index = []
for i in range(X[0]):
	if MyDict.get(List[i]) == 0:
		Index.append(i)
Check = 1
for i in range(1, X[1]):
	Check *= Index[i] - Index[i - 1]
	Check %= 998244353
print(sum(MyDict), Check)


(N, M) = map(int, input().split())
mod = 998244353
X = list(map(int, input().split()))
r1 = N * (N + 1) // 2 - (N - M) * (N - M + 1) // 2
j = None
r = 1
for (i, x) in enumerate(X):
	if x <= N - M:
		continue
	if j == None:
		j = i
		continue
	k = i - j
	r = k * r % mod
	j = i
print(r1, r)


(n, k) = map(int, input().split(' '))
p = list(map(int, input().split(' ')))
pcpy = p.copy()
p.sort(reverse=True)
thres = p[k - 1]
ans = 1
rem = 0
flag = False
cnt = 0
M = 998244353
for i in range(n):
	if flag:
		if thres > pcpy[i]:
			rem += 1
		else:
			rem += 1
			ans *= rem
			cnt += 1
			rem = 0
	if thres <= pcpy[i] and (not flag):
		flag = True
	if cnt >= k - 1:
		break
print(sum(p[:k]), ans % M)


import sys
input = sys.stdin.readline
(x, y) = map(int, input().split())
(*li,) = map(int, input().split())
ans = 1
sum1 = 0
li1 = []
for i in range(x):
	if li[i] > x - y:
		sum1 += li[i]
		li1.append(i + 1)
for i in range(y - 1):
	ans = ans * (li1[i + 1] - li1[i]) % 998244353
print(sum1, ans)


mod = 998244353
(n, k) = map(int, input().strip().split())
permutation = list(map(int, input().strip().split()))
cutoffs = []
maxVal = 0
for j in range(n):
	if permutation[j] > n - k:
		maxVal += permutation[j]
		cutoffs.append(j)
timesReached = 1
for j in range(1, len(cutoffs)):
	timesReached *= cutoffs[j] - cutoffs[j - 1]
	timesReached = timesReached % mod
print(maxVal, timesReached)


mod = 998244353
a = input().split(' ')
n = int(a[0])
k = int(a[1])
a = input().split(' ')
s = 0
for i in range(n - k + 1, n + 1):
	s += i
val = []
for i in range(n):
	a[i] = int(a[i])
	if a[i] > n - k:
		val.append(i)
m = len(val)
ans = 1
for i in range(1, m):
	ans = ans * (val[i] - val[i - 1]) % mod
print(s, ans)


from sys import stdin, stdout
(n, k) = stdin.readline().split()
n = int(n)
k = int(k)
numbers = list(map(int, stdin.readline().split()))

def getAns(L, n, k):
	maxValue = k * (2 * n + 1 - k) >> 1
	for i in range(n):
		if n - k < L[i]:
			lowest = i
			break
	tmp = lowest
	prod = 1
	for i in range(lowest + 1, n):
		if n - k < L[i]:
			prod = prod * (i - tmp) % 998244353
			tmp = i
	return (maxValue, prod)
(maxValue, prod) = getAns(numbers, n, k)
stdout.write(str(maxValue) + ' ' + str(prod % 998244353))


MOD = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(sorted(p, reverse=True)[:k])
ind = set(sorted(p, reverse=True)[:k])
mn = n
mx = 0
for i in range(n):
	if p[i] in ind:
		mn = min(mn, i)
		mx = max(mx, i)
i = mn
mult = 1
while i < mx:
	j = i + 1
	ct = 1
	while j < mx and p[j] not in ind:
		j += 1
		ct += 1
	mult = mult * ct % MOD
	i = j
print(s, mult)


(n, k) = list(map(lambda x: int(x), input().split()))
p = list(map(lambda x: int(x), input().split()))
mod = 998244353
ps = sorted(p, reverse=True)[:k]
ans1 = sum(ps)
d = {}
for x in ps:
	d[x] = True
ans2 = 1
i = 0
Z = 0
while Z < k - 1:
	if p[i] in d:
		Z += 1
		j = i + 1
		while p[j] not in d:
			j += 1
		ans2 *= j - i
		ans2 %= mod
		i = j
	else:
		i += 1
print(str(ans1) + ' ' + str(ans2))


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sum = (2 * n - k + 1) * k // 2
lo = n - k + 1
cnt = 0
b = []
for i in a:
	if i >= lo:
		b.append(cnt)
		cnt = 0
	else:
		cnt += 1
b.append(cnt)
ans = 1
mod = 998244353
for i in range(1, len(b) - 1):
	ans = ans * (b[i] + 1) % mod
print(sum, ans)


M = 998244353
(n, k) = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
upper = n
lower = n - k + 1
nTerms = k
maxVal = (lower + upper) * nTerms // 2
isMaxTerm = [False for _ in range(n)]
firstMaxIdx = -1
lastMaxIdx = -1
for i in range(n):
	if lower <= p[i] <= upper:
		if firstMaxIdx == -1:
			firstMaxIdx = i
		lastMaxIdx = i
		isMaxTerm[i] = True
ans = 1
l = 1
for i in range(firstMaxIdx, lastMaxIdx + 1):
	if isMaxTerm[i]:
		ans = ans * l
		ans = ans % M
		l = 1
	else:
		l += 1
print('{} {}'.format(maxVal, ans))


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split(' '))
array = list(map(int, stdin.readline().split(' ')))
indices = []
for i in range(n):
	if n - k + 1 <= array[i] <= n:
		indices.append(i)
MOD = 998244353
s = array[indices[0]]
counter = 1
for i in range(1, k):
	counter = counter * (indices[i] - indices[i - 1]) % MOD
	s += array[indices[i]]
stdout.write(str(s) + ' ' + str(counter))


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

def get_str():
	return input().decode().strip()

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

def oint():
	return int(input())
(n, k) = rint()
p = list(rint())
pi = [i for i in range(n)]
pi.sort(key=lambda e: -p[e])
pi = pi[:k]
pi.sort()
c = 1
for i in range(len(pi) - 1):
	c *= pi[i + 1] - pi[i]
	c %= 998244353
v = 0
for i in range(len(pi)):
	v += p[pi[i]]
print(v, c)


import sys

def cmp(a):
	return a[0]
MOD = 998244353
n = list(map(int, input().split(' ')))
k = n[1]
n = n[0]
p = list(map(int, input().split(' ')))
for i in range(0, n):
	p[i] = (p[i], i)
q = sorted(p, reverse=True, key=cmp)
ans1 = 0
ans2 = 1
for i in range(0, k):
	p[q[i][1]] = (-1, -1)
	ans1 += q[i][0]
len = 1
chk = True
for i in range(0, n):
	if p[i][1] == -1 and chk:
		chk = False
		len = 1
		continue
	elif p[i][1] == -1:
		ans2 *= len
		ans2 %= MOD
		len = 1
		continue
	len += 1
print(ans1, ans2, sep=' ')


(n, k) = [int(i) for i in input().split()]
sc = 1
sm = 0
rz = 0
for i in input().split():
	i = int(i)
	if i > n - k:
		if rz:
			rz = rz * sc % 998244353
			sc = 1
			sm += i
		else:
			rz = 1
			sc = 1
			sm += i
	else:
		sc += 1
print(sm, rz)


(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
md = {}
for i in range(n):
	md[arr[i]] = i + 1
mxv = 0
idx = []
for i in sorted(md):
	if i > n - k:
		mxv += i
		idx.append(md[i])
mxvs = 1
idx = sorted(idx)
mod = 998244353
for i in range(len(idx) - 1, 0, -1):
	tidx = idx[i] - idx[i - 1]
	mxvs = mxvs % mod * (tidx % mod) % mod
print(mxv, mxvs)


from sys import stdin
inf = stdin
(n, k) = map(int, inf.readline().split(' '))
arr = list(map(int, inf.readline().split(' ')))
arr1 = []
for i in range(n):
	arr1.append([arr[i], i])
arr1.sort(reverse=True)
index = []
val = 0
for i in range(k):
	index.append(arr1[i][1])
	val += arr1[i][0]
index.sort()
ans = 1
for i in range(1, k):
	ans *= index[i] - index[i - 1]
	ans = ans % 998244353
print(val, ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(input())
P = 1000000007

def main():
	(n, k) = In()
	arr = L()
	dict1 = {}
	for i in range(n):
		dict1[arr[i]] = 0
	lis = sorted(arr)[n - k:n]
	for i in range(k):
		dict1[lis[i]] = 1
	flag = 0
	sm = 1
	for i in range(n):
		if flag == 0 and dict1[arr[i]] == 1:
			flag = 1
			val = i
		elif flag == 1 and dict1[arr[i]] == 1:
			sm *= i - val
			sm %= 998244353
			val = i
	print(sum(lis), sm % 998244353)
main()


list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
n = list1[0]
k = list1[1]
ans1 = 0
if k == 1:
	print(n, end=' ')
	print(1)
else:
	for i in range(n, n - k, -1):
		ans1 += i
	ans2 = 1
	indexes = []
	for i in range(n):
		if list2[i] > n - k:
			indexes.append(i)
	for i in range(k - 1):
		ans2 = ans2 * (indexes[i + 1] - indexes[i])
	print(ans1, end=' ')
	print(ans2 % 998244353)


l1 = input().split(' ')
n = int(l1[0])
k = int(l1[1])
p = input().split(' ')
p = [int(i) for i in p]
pv = k * (2 * n - k + 1) / 2
ans = 1
prev = -1
small = n - k + 1
MOD = 998244353
for i in range(len(p)):
	if p[i] >= small:
		if prev == -1:
			prev = i
			continue
		ans *= i - prev
		ans %= MOD
		prev = i
print(int(pv), ans)


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
MOD = 998244353
(n, k) = rl()
p = rl()
s = 0
x = 1
j = None
for i in range(n):
	if p[i] > n - k:
		s += p[i]
		if j is not None:
			x = x * (i - j) % MOD
		j = i
print(s, x)


(n, k) = map(int, input().split())
ps = list(map(int, input().split()))
pss = sorted(ps)
v = sum(pss[-k:])
t = pss[-k]
cnt = 1
lasti = -1
for (i, p) in enumerate(ps):
	if p >= t:
		if lasti != -1:
			cnt = cnt * (i - lasti) % 998244353
		lasti = i
print(v, cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = 0
l = -1
r = 0
c = 1
for i in range(n):
	if n >= a[i] > n - k:
		if l == -1:
			r = i
			l = r
		else:
			l = r
			r = i
			c *= r - l
		b += a[i]
print(str(b) + ' ' + str(c % 998244353))


(n, k) = [int(i) for i in input().split()]
per = [int(i) for i in input().split()]
if n == k:
	print((n ** 2 + n) // 2, 1)
else:
	s = (n ** 2 + n) // 2 - ((n - k) ** 2 + (n - k)) // 2
	r = []
	for j in range(n):
		if per[j] + k > n:
			r.append(j)
	t = 1
	for i in range(k - 1):
		t *= r[i + 1] - r[i]
	print(s, t % 998244353)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
dic = {}
li = []
for i in range(n - k + 1, n + 1):
	dic[i] = 0
ans1 = sum(list(dic.keys()))
ans2 = 1
boo = True
mark = 0
for i in range(n):
	if a[i] in dic.keys() and boo:
		mark = i
		boo = False
		continue
	if a[i] in dic.keys():
		ans2 *= i - mark
		mark = i
print(ans1, ans2 % 998244353)


import math
from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
ls2 = [(i, ls[i]) for i in range(n)]
ls2.sort(key=lambda x: x[1])
ls2.reverse()
arr = [ls2[i][0] for i in range(k)]
arr.sort()
prod = 1
s = ls[arr[0]]
for i in range(k - 1):
	prod = prod * (arr[i + 1] - arr[i]) % 998244353
	s += ls[arr[i + 1]]
print(str(s) + ' ' + str(prod) + '\n')


(n, k) = map(int, input().split())
permutation = list(map(int, input().split()))
s_permutation = sorted(permutation, reverse=True)
a1 = sum(s_permutation[:k])
nums = set()
for i in s_permutation[:k]:
	nums.add(i)
a2 = 1
prev = 0
flag = False
for j in range(n):
	if permutation[j] in nums:
		if not flag:
			prev = 0
			flag = True
		else:
			prev += 1
			a2 = a2 * prev % 998244353
			prev = 0
	else:
		prev += 1
print(a1, a2)


(n, k) = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
mod = 998244353
l = []
for i in range(n):
	l.append([p[i], i])
l.sort(key=lambda x: x[0], reverse=True)
val = []
total = 0
for i in range(k):
	total += l[i][0]
	val.append(l[i][1])
val.sort()
ans = 1
for i in range(1, k):
	ans = ans * (val[i] - val[i - 1]) % mod
print(total, ans)


from sys import stdin, stdout

def main():
	(n, k) = list(map(int, stdin.readline().split()))
	arr = list(map(int, stdin.readline().split()))
	ans = 1
	mul = 1
	start_yet = False
	sum = 0
	for y in arr:
		if y > n - k:
			if start_yet is False:
				start_yet = True
			else:
				ans *= mul
				ans %= 998244353
			mul = 1
			sum += y
		else:
			mul += 1
	stdout.write(str(sum) + ' ' + str(ans))
main()


from math import sqrt
from queue import Queue
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 998244353
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
pos = []
pre = -1
for (i, ai) in enumerate(a):
	if ai > n - k:
		if pre == -1:
			pre = i
		else:
			pos.append(i - pre)
			pre = i
ans = 1
for poi in pos:
	ans = ans * poi % MOD
print((n + n - k + 1) * k // 2, ans)


(n, k) = map(int, input().split())
mod = 998244353
a = list(map(int, input().split()))
cnt = 1
poss = 1
first = True
for i in range(n):
	if a[i] <= n - k:
		cnt += 1
		continue
	else:
		if first:
			first = False
			cnt = 1
			continue
		poss *= cnt
		poss %= mod
		cnt = 1
ans1 = 0
for i in range(k):
	ans1 += n
	n -= 1
print(ans1, poss)


(n, k) = list(map(int, input().rstrip().split()))
p = list(map(int, input().rstrip().split()))
l = []
ans2 = 1
for i in range(len(p)):
	if p[i] <= n and p[i] >= n - (k - 1):
		l.append(i)
for j in range(len(l) - 1):
	ans2 *= (l[j + 1] - l[j]) % 998244353
	ans2 = ans2 % 998244353
ans1 = n * k
ans1 -= (k - 1) * k // 2
print(str(ans1) + ' ' + str(ans2))


MOD = 998244353

def main():
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	t = n - k + 1
	x = (n + t) * k // 2
	y = 1
	tmp = 1
	flg = False
	for i in range(n):
		if p[i] >= t:
			if flg:
				y *= tmp
				y %= MOD
			else:
				flg = True
			tmp = 1
		else:
			tmp += 1
	print(x, y)
main()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
mod = 998244353
if n == k:
	print(n * (n + 1) // 2, 1)
	exit()
ans = n * k - k * (k - 1) // 2
indxs = list()
for i in range(n):
	if p[i] > n - k:
		indxs.append(i)
count = 1
for i in range(1, len(indxs)):
	count = count * (indxs[i] - indxs[i - 1]) % mod
print(ans, count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
idxs = []
track = n
prev = 0
s = 0
for i in range(n):
	if n - k + 1 <= a[i] <= n:
		idxs.append(i)
		s += a[i]
ans = 1
for i in range(1, len(idxs)):
	ans *= idxs[i] - idxs[i - 1]
print(s, ans % 998244353)


(n, k) = input().split()
n = int(n)
k = int(k)
l = list(map(int, input().split()))
temp = l.copy()
temp.sort(reverse=True)
ind = []
for j in range(n):
	if l[j] > n - k:
		ind.append(j)
ind.sort()
ans = 0
if not len(ind):
	ans = 0
elif len(ind) == 1:
	ans = 1
else:
	ans = 1
	for i in range(1, len(ind)):
		ans *= ind[i] - ind[i - 1]
print(k * (2 * n - k + 1) // 2, ans % 998244353)


(n, k) = map(int, input().split())
ar = [int(x) for x in input().split()]
val = n
d = {}
k2 = k
md = 998244353
fsm = 0
while k2 != 0:
	d[val] = 1
	fsm += val
	val -= 1
	k2 -= 1
pos = []
for i in range(n):
	if ar[i] in d:
		pos.append(i)
sm = 1
for i in range(k - 1):
	dif = pos[i + 1] - pos[i]
	sm *= dif
	sm = sm % md
print(fsm, sm)


m = 998244353
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
v = sorted(l, reverse=True)
s = sum(v[:k])
d = {}
for t in v[:k]:
	d[t] = 1
ax = []
for t in range(n):
	if d.get(l[t]) == 1:
		ax.append(t)
ans = 1
for t in range(1, len(ax)):
	ans *= (ax[t] - ax[t - 1]) % m
	ans %= m
print(s, ans)


import sys

def input():
	return sys.stdin.buffer.readline()[:-1]
(n, k) = [int(x) for x in input().split()]
a = [(int(x), i) for (i, x) in enumerate(input().split())]
a.sort(key=lambda x: (-x[0], x[1]))
a = a[:k]
a.sort(key=lambda x: x[1])
res = 1
for i in range(1, len(a)):
	(_, x) = a[i - 1]
	(_, y) = a[i]
	res *= y - x
	res %= 998244353
sm = sum([x for (x, _) in a])
print(sm, res)


MOD = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
rng = set(range(n - k + 1, n + 1))
print(sum(rng), end=' ')
comb = 1
prev = -1
for i in range(n):
	if p[i] in rng:
		if prev != -1:
			comb *= i - prev
			comb %= MOD
		prev = i
print(comb)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
	b.append((a[i], i))
b.sort()
b.reverse()
b = b[:k]
c = []
s = 0
for i in range(len(b)):
	s += b[i][0]
	c.append(b[i][1])
f = 1
c.sort()
for i in range(1, len(c)):
	f = f * (c[i] - c[i - 1])
print(s, f % 998244353)


mod = 998244353
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
maxi = []
for i in range(n):
	if a[i] <= n and a[i] > n - k:
		maxi.append(i)
sum = 0
num = 1
for i in range(k):
	sum += n - i
for i in range(1, k):
	num *= maxi[i] - maxi[i - 1]
	num %= mod
print(sum, num)


import sys
input = sys.stdin.readline
(n, k) = [int(x) for x in input().strip().split()]
p = [int(x) for x in input().strip().split()]
MOD = 998244353
m = n - k
ans = 1
s = 0
pi = 0
while p[pi] <= m:
	pi += 1
prev = pi
s += p[pi]
pi += 1
while pi < n:
	if p[pi] > m:
		ans *= pi - prev
		s += p[pi]
		prev = pi
		ans %= MOD
	pi += 1
print(s, ans)


import sys, math
q = 1
for _ in range(q):
	(n, k) = map(int, sys.stdin.readline().split())
	l = list(map(int, sys.stdin.readline().split()))
	ans1 = 0
	for i in range(n, n - k, -1):
		ans1 += i
	a = []
	for i in range(n):
		if l[i] > n - k:
			a.append(i + 1)
	b = []
	for i in range(len(a) - 1):
		b.append(a[i + 1] - a[i])
	m = 998244353
	ans2 = 1
	for i in range(len(b)):
		ans2 = ans2 * b[i] % m
	print(ans1, ans2 % m)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = A.copy()
B.sort(reverse=True)
t = B[:k]
Ans = []
d = {}
for i in range(n):
	d[A[i]] = i
for i in t:
	Ans.append(d[i])
Ans.sort()
m = 1
for i in range(1, len(Ans)):
	m *= Ans[i] - Ans[i - 1]
print(sum(t), m % 998244353)


def main_function():
	(n, k) = list(map(int, input().split(' ')))
	P = list(map(int, input().split(' ')))
	prev = None
	ans1 = 0
	ans2 = 1
	for i in range(len(P)):
		if P[i] >= n - k + 1:
			ans1 += P[i]
			if prev is None:
				prev = i
			else:
				ans2 *= i - prev
				ans2 %= 998244353
				prev = i
	print(ans1, 1 if k == 1 else ans2)
main_function()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
print((n + n - k + 1) * k // 2, end=' ')
x = [1 for i in range(k + 1)]
maxx = n - k
cur = 0
j = 0
for i in range(n):
	if p[i] > maxx:
		x[j] = cur + 1
		cur = 0
		j = j + 1
	else:
		cur += 1
mad = 998244353
ans = 1
for i in range(1, k):
	ans = ans * x[i] % mad
print(ans)


(n, k) = map(int, input().split())
pl = list(map(int, input().split()))
MOD = 998244353
N = 10 ** 5
fact = [1] * (N + 1)
rfact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
	fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD - 2, MOD)
for i in range(N, 0, -1):
	rfact[i - 1] = r = r * i % MOD

def perm(n, k):
	return fact[n] * rfact[n - k] % MOD

def comb(n, k):
	return fact[n] * rfact[k] * rfact[n - k] % MOD
ans = 1
target_idx = []
for (idx, p) in enumerate(pl):
	if p >= n - k + 1:
		target_idx.append(idx)
for i in range(len(target_idx) - 1):
	ans *= target_idx[i + 1] - target_idx[i]
	ans %= MOD
print((2 * n + 1 - k) * k // 2, ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
import sys

def main():
	mod = 998244353
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	a = set(range(n - k + 1, n + 1))
	b = 1
	t = -1
	for i in range(n):
		if p[i] in a:
			if t == -1:
				t = i
			else:
				b = b * (i - t) % mod
				t = i
	print(sum(a), b)
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')
main()


from sys import stdin

def read():
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	return (n, k, a)

def solve(n, k, a):
	s = (n + (n - k + 1)) * k // 2
	base = n - k
	prev = -1
	total = 1
	for i in range(n):
		if a[i] > base:
			if prev != -1:
				total *= i - prev
				total %= 998244353
			prev = i
	return (s, total)
result = solve(*read())
print(*result)


def main():
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	new_p = []
	for i in range(n):
		new_p.append([p[i], i])
	new_p = sorted(new_p, key=lambda x: x[0], reverse=True)
	new_p = new_p[0:k]
	new_p = sorted(new_p, key=lambda x: x[1])
	sm = 0
	r = 1
	for i in range(0, k - 1):
		sm += new_p[i][0]
		r *= new_p[i + 1][1] - new_p[i][1]
		r = r % 998244353
	sm += new_p[-1][0]
	print(sm, r)
	return
main()


from math import *
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
m = 998244353
r = []
for i in range(k):
	s = s + n - i
q = []
for i in range(n):
	if l[i] > n - k:
		q.append(i)
f = 1
q.sort()
for i in range(1, len(q)):
	p = q[i] - q[i - 1]
	f = f * p % m
print(s, f % m)


mod = 998244353
(n, k) = map(int, input().strip().split())
nums = [int(i) for i in input().strip().split()]
ans = (1 + n) * n // 2 - (1 + (n - k)) * (n - k) // 2
small = n - k + 1
l = 0
r = n - 1
for i in range(n):
	if small <= nums[i] <= n:
		l = i
		break
for i in range(n - 1, -1, -1):
	if small <= nums[i] <= n:
		r = i
		break
for i in range(l, r + 1):
	if small <= nums[i] <= n:
		continue
	else:
		l = i - 1
		break
for i in range(r - 1, l - 1, -1):
	if small <= nums[i] <= n:
		continue
	else:
		r = i + 1
		break
if l >= r:
	print(ans, 1)
else:
	an = 1
	cnt = 1
	for i in range(l, r + 1):
		if small <= nums[i] <= n:
			an *= cnt
			an = an % mod
			cnt = 1
		else:
			cnt += 1
	print(ans, an)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted([(a[i], i) for i in range(n)], key=lambda x: (-1 * x[0], x[1]))
answer = 0
count = 1
j = k
mod = 998244353
while j < n and b[j][0] == b[k - 1][0]:
	j += 1
b = b[:k - 1] + [b[j - 1]]
for j in range(len(b)):
	answer += b[j][0]
b.sort(key=lambda x: x[1])
for j in range(1, len(b)):
	count *= b[j][1] - b[j - 1][1]
	count %= mod
print(answer, count)


from functools import reduce
MOD = 998244353
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
m = n - k + 1
bs = list(map(lambda p: p[0], filter(lambda p: p[1] >= m, enumerate(arr))))
it = iter(bs)
next(it)
ans = reduce(lambda s, p: s * (p[1] - p[0]) % MOD, zip(iter(bs), it), 1)
print((n + m) * k // 2, ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ll = [(l[i], i) for i in range(n)]
ll.sort(reverse=True)
ind = []
su = 0
for i in range(m):
	ind.append(ll[i][1])
	su += ll[i][0]
ind.sort()
mul = 1
mod = 998244353
for i in range(1, len(ind)):
	mul = mul % mod * (ind[i] - ind[i - 1]) % mod % mod
print(su, mul)


import sys
import random
from math import log2, log, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a > 0:
		return gcd(b % a, a)
	return b

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
(n, k) = int_array()
a = int_array()
inds = []
sum = 0
for i in range(n):
	if a[i] > n - k:
		sum += a[i]
		inds.append(i)
ways = 1
for i in range(len(inds) - 1):
	ways *= (inds[i + 1] - inds[i]) % 998244353
print(*(sum, ways % 998244353))


(n, k) = [int(x) for x in input().split()]
arr = [[int(x), i] for (i, x) in enumerate(input().split())]
arr.sort(reverse=True)
res = 0
index = []
for i in range(k):
	res += arr[i][0]
	index.append(arr[i][1])
index.sort()
i = 0
c = 1
while i < len(index) - 1:
	c *= index[i + 1] - index[i]
	c %= 998244353
	i += 1
print(str(res) + ' ' + str(c))


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()
mod = 998244353
t = 1
for _x in range(t):
	(n, k) = ilist()
	arr = ilist()
	maxi = 0
	(ans1, ans2) = (0, 1)
	k1 = 0
	while k != k1:
		ans1 += n - k1
		k1 += 1
	helper = []
	for (i, x) in enumerate(arr):
		if x >= n - k + 1:
			helper.append(i)
	helper.sort()
	for i in range(1, len(helper)):
		ans2 = ans2 * (helper[i] - helper[i - 1]) % mod
	print(ans1, ans2)


import sys
import math
from itertools import permutations
input = sys.stdin.readline
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
fin = []
m = 998244353
for i in range(n):
	if arr[i] > n - k:
		fin.append(i)
tot = 1
for i in range(1, len(fin)):
	tot *= (fin[i] - fin[i - 1]) % m
	tot = tot % m
x = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
print(x, tot)


(n, k) = list(map(int, input().split()))
i = -1

def fun(x):
	global i
	i = i + 1
	return (int(x), i)
d = dict(map(fun, input().split()))
l = [d[j] for j in range(n - k + 1, n + 1)]
l.sort()
m = 1
for i in range(k - 1):
	m = m * (l[i + 1] - l[i])
print(int((2 * k * n - k ** 2 + k) / 2), m % 998244353)


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(n, k) = idata()
	p = idata()
	s = n - k
	print(n * (n + 1) // 2 - s * (s + 1) // 2, end=' ')
	data = [0] * k
	(z, flag) = (0, True)
	for i in range(n):
		if flag:
			if p[i] > s:
				data[z] += 1
				flag = False
		else:
			if p[i] > s:
				z += 1
			data[z] += 1
	ans = 1
	for i in range(len(data) - 1):
		ans *= data[i]
	print(ans % 998244353)
	return
for ______ in range(1):
	solve_of_problem()


import sys
(n, k) = map(int, input().split())
mas = list(map(int, input().split()))
cou = []
for i in range(n):
	cou.append(0)
for i in range(n):
	if mas[i] >= n - k + 1:
		cou[i] = 1
suma = 0
for i in range(n - k + 1, n + 1, 1):
	suma += i
print(suma, end=' ')
ans = 1
mod = 998244353
now = 0
while cou[now] != 1:
	now += 1
while now < n:
	now += 1
	kol = 0
	while now < n and cou[now] != 1:
		now += 1
		kol += 1
	if now < n:
		ans *= kol + 1
	ans %= mod
print(ans)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
(n, k) = mi()
d = li()
prev = -1
res = 1
m = 998244353
for i in range(n):
	if n - k < d[i] <= n:
		if prev != -1:
			res *= i - prev
			res %= m
		prev = i
print(n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2, res)


(n, k) = map(int, input().split())
s = map(int, input().split())
s = list(s)
i = j = 0
m = n - k
ans = 1
mod = 998244353
for (i, x) in enumerate(s):
	if x > m:
		break
s = s[i:]
for i in range(len(s) - 1, -1, -1):
	if s[i] <= m:
		s.pop()
	else:
		break
i = j = 0
while j != len(s):
	if s[j] > m:
		ans *= j - i + 1
		ans %= mod
		j += 1
		i = j
	else:
		j += 1
print(k * (n + n - k + 1) // 2, ans)


def sortt(x):
	return x[0]
(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([s[i], i])
b.sort(key=sortt, reverse=True)
ans = 0
pos = []
for i in range(k):
	ans += b[i][0]
	pos.append(b[i][1])
pos.sort()
els = 1
for i in range(k - 1):
	els *= pos[i + 1] - pos[i]
print(ans, els % 998244353)


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
m = []
ans = 0
for i in range(n):
	if l[i] > n - k:
		index = i
		ans += l[i]
		break
value = 1
for i in range(i + 1, n):
	if l[i] > n - k:
		value = value * (i - index) % 998244353
		index = i
		ans += l[i]
print(ans, value)


import os
import sys
M = 998244353

def Partitions(n, k, llist):
	global M
	ans1 = 0
	ans2 = 1
	Set = set()
	res = []
	for i in range(k):
		ans1 += n - i
		Set.add(n - i)
	for i in range(len(llist)):
		if llist[i] in Set:
			res.append(i)
	for j in range(0, len(res) - 1):
		ans2 *= (res[j + 1] - res[j]) % M
	return [ans1, ans2 % M]
(n, k) = tuple(map(int, input().split()))
llist = list(map(int, input().split()))
result = Partitions(n, k, llist)
print(*result)


MOD = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
s = (2 * n - k + 1) * k // 2
ans = 1
j = -1
for i in range(n):
	if p[i] >= n - k + 1:
		if j != -1:
			ans *= i - j
			ans %= MOD
		j = i
print(s, ans)


(a, b) = list(map(int, input().split()))
l = list(map(int, input().split()))
mod = 998244353
nums = []
c = 0
for i in range(a):
	if l[i] < a - b + 1:
		c += 1
	else:
		nums.append(c)
		c = 0
ans = 1
for i in range(1, len(nums)):
	ans *= nums[i] + 1
	ans = ans % mod
tot = (a - (b - 1) / 2) * b
print(int(tot), ans)


(n, k) = (int(i) for i in input().split(' '))
p = [int(i) for i in input().split(' ')]
ix = []
for i in range(len(p)):
	if n - p[i] < k:
		ix.append(i)
ix.sort()
c = 1
for i in range(1, len(ix)):
	c *= ix[i] - ix[i - 1]
print(((n + 1) * n - (n - k + 1) * (n - k)) // 2, c % 998244353)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
mod = 998244353
(n, k) = mdata()
P = list(mdata())
for i in range(n):
	P[i] = [P[i], i]
P1 = sorted(P, key=lambda x: x[0], reverse=True)
m = 0
ans = 1
l = []
for i in range(k):
	m += P1[i][0]
	l.append(P1[i][1])
l.sort(reverse=True)
for i in range(len(l) - 1):
	ans = ans * (l[i] - l[i + 1]) % mod
print(m, ans)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
a = sorted(p, reverse=True)
b = sum(a[:k])
c = set(a[:k])
d = 0
e = []
for i in range(n):
	if p[i] in c:
		e.append(d)
		d = 0
	else:
		d = d + 1
e.append(d)
s = 1
for i in range(1, len(e) - 1):
	s = s * (e[i] + 1)
print(b, s % 998244353)


def f1():
	T = int(input())
	for i in range(0, T):
		t = int(input())
		if t == 1:
			print(-1)
			continue
		intx = ''
		for k in range(t - 1):
			intx = intx + '7'
		intx = int(intx)
		for j in range(3, 10):
			if j != 7:
				a = (intx * 10 + j) % 7
				b = (intx * 10 + j) % j
				if a != 0 and b != 0:
					num = intx * 10 + j
					print(num)
					break

def f2():
	N = int(input())
	B = [int(i) for i in input().split(' ')]
	A = [-1] * len(B)
	A[0] = B[0]
	A[1] = B[1] + max(0, A[0])
	lastmax = max(A[1], A[0])
	for i in range(2, len(B)):
		A[i] = B[i] + max(A[i - 1], lastmax)
		lastmax = max(A[i - 1], lastmax)
	for j in range(0, len(A)):
		print(A[j], end=' ')

def f3():
	NK = input().split(' ')
	(N, K) = (int(NK[0]), int(NK[1]))
	PERMUTE = [int(i) for i in input().split(' ')]
	GNGT = N - K + 1
	ARRAY = [False] * len(PERMUTE)
	MIDDLE_ELEMENTS = list()
	MAXSUM = 0
	first = 0
	for i in range(0, len(PERMUTE)):
		if PERMUTE[i] >= GNGT:
			MAXSUM = MAXSUM + PERMUTE[i]
			ARRAY[i] = True
	lasttrue = -1
	answer = -1
	for i in range(0, len(ARRAY)):
		if ARRAY[i] == True:
			if answer == -1:
				answer = 1
				lasttrue = i
			else:
				thistrue = i
				elements_in_between = thistrue - lasttrue - 1
				elements_in_between = elements_in_between + 1
				lasttrue = thistrue
				answer = answer * elements_in_between
				answer = answer % 998244353
	print(MAXSUM, answer % 998244353)

def palin(s):
	if len(s) == 0 or len(s) == 1:
		return s
	split = 0
	i = 0
	r = l = 0
	pstr = ''
	sx = 0
	ex = 0
	maxc = 0
	while i < len(s):
		if split == 0:
			split = 0.5
			l = i - 1
			r = i + 1
			while l >= 0 and r < len(s):
				if s[l] == s[r]:
					if maxc < r - l:
						maxc = r - l
						sx = l
						ex = r
					l = l - 1
					r = r + 1
				else:
					break
		if split == 0.5:
			split = 0
			l = i
			r = i + 1
			while l >= 0 and r < len(s):
				if s[l] == s[r]:
					if maxc < r - l:
						maxc = r - l
						sx = l
						ex = r
					l = l - 1
					r = r + 1
				else:
					break
		i = i + 1
	return s[sx:ex + 1]
f3()


(n, k) = [int(x) for x in input().split()]
perm = [int(x) for x in input().split()]
(posPre, posCur) = (-1, -1)
res = 1
for i in range(n):
	if perm[i] > n - k:
		if posCur < 0:
			posCur = i
		else:
			(posPre, posCur) = (posCur, i)
			res = res * (posCur - posPre) % 998244353
print((n + n - k + 1) * k // 2, res)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ans1 = k * (n - k + 1 + n) // 2
t = []
for (i, j) in enumerate(p):
	if j >= n - k + 1 and j <= n:
		t.append(i)
ans2 = 1
for i in range(len(t) - 1):
	ans2 *= t[i + 1] - t[i]
	ans2 %= 998244353
print(ans1, ans2)


m = 998244353
(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ind = []
ans1 = sum(range(n, n - k, -1))
for i in range(n):
	if n >= p[i] >= n - k + 1:
		ind.append(i)
b = [ind[i] - ind[i - 1] for i in range(1, len(ind))]
ans = 1
for i in range(len(b)):
	ans = ans % m * b[i] % m % m
print(ans1, ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
m = n - k + 1
pos = []
(ans, an) = (0, 1)
for i in range(n):
	if p[i] >= m:
		pos.append(i)
		ans += p[i]
for i in range(len(pos) - 1):
	an *= pos[i + 1] - pos[i]
print(ans, an % 998244353)


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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
(n, k) = RL()
p = RLL()
data = sorted(p)
key = data[-k]
r1 = sum(data[-k:])
r2 = 1
tmp = 1
s = 0
while p[s] < key:
	s += 1
c = 0
for i in p[s:]:
	if i >= key:
		r2 *= tmp
		tmp = 1
		c += 1
	else:
		tmp += 1
	if c >= k:
		break
print(r1, r2 % 998244353)


import os
import sys
from math import *
from collections 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()]
m = 998244353
(n, k) = value()
a = array()
s = set([i for i in range(n, n - k, -1)])
c = 0
for i in range(n):
	if a[i] in s:
		ind = i
		break
ans = 1
for i in range(ind + 1, n):
	if a[i] in s:
		ans *= (i - ind) % m
		ind = i
print(sum(s), ans % m)


import heapq
(n, k) = map(int, input().split())
c = list(map(int, input().split()))
h = []
for i in range(n):
	heapq.heappush(h, (c[i], i))
	if len(h) == k + 1:
		heapq.heappop(h)
h = [h[i][1] for i in range(k)]
h.sort()
ans1 = 0
ans2 = 1
for i in h:
	ans1 += c[i]
for i in range(k - 1):
	ans2 = ans2 * (h[i + 1] - h[i]) % 998244353
print(ans1, ans2)


mod = 998244353
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
r = n
for i in range(k):
	ans += r
	r -= 1
r = []
for i in range(n):
	if a[i] in range(n - k + 1, n + 1):
		r.append(i)
an = 1
for i in range(k - 1):
	an *= r[i + 1] - r[i]
	an %= mod
print(ans, an)


(n, k) = [int(a) for a in input().split(' ')]
v = [int(a) for a in input().split(' ')]
mod = 998244353
positions = []
for i in range(0, n):
	if v[i] > n - k:
		positions.append(i)
ways = []
for i in range(0, k - 1):
	ways.append(positions[i + 1] - positions[i])
res = 1
for i in range(0, k - 1):
	res *= ways[i]
max_sum = int(n * (n + 1) / 2)
max_sum -= int((n - k) * (n - k + 1) / 2)
print(max_sum, res % mod)


tmp = input().split(' ')
(n, k) = (int(tmp[0]), int(tmp[1]))
p = list(map(lambda x: int(x), input().split(' ')))
ind = []
for i in range(len(p)):
	if p[i] > n - k:
		ind.append(i)
ans = 1
for i in range(1, len(ind)):
	ans = ans * (ind[i] - ind[i - 1]) % 998244353
num = int(n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2)
print(num, ans)


from math import ceil, sqrt, log

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
mod = 998244353

def main():
	(n, k) = mi()
	a = li()
	x = []
	for i in range(n):
		b = []
		b.append(a[i])
		b.append(i)
		x.append(b)
	x.sort(reverse=True)
	c = []
	s = 0
	for i in range(k):
		c.append(x[i][1])
		s += x[i][0]
	c.sort()
	print(s, end=' ')
	ans = 1
	for i in range(1, k):
		a = c[i] - c[i - 1]
		ans = ans % mod * a % mod % mod
	print(ans)
main()


R = lambda : map(int, input().split())
(n, k) = R()
a = list(R())
N = 998244353

def solve(a, k):
	s = 0
	first = False
	count = 0
	ans = 1
	for i in range(len(a)):
		if first:
			count += 1
		if a[i] > n - k:
			s += a[i]
			if first:
				ans = ans * count % N
			first = True
			count = 0
	return [s, ans]
print(*solve(a, k))


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
sum1 = 0
for i in range(n - 1, n - k - 1, -1):
	sum1 += l[i]
pos = []
left = l[n - k]
right = l[n - 1]
for i in range(n):
	if left <= p[i] <= right:
		pos.append(i)
res = 1
lent = len(pos)
for i in range(1, lent):
	res *= pos[i] - pos[i - 1]
	res %= 998244353
print(sum1, res % 998244353)


(n, k) = [int(x) for x in input().strip().split()]
arr = [int(x) for x in input().strip().split()]
mod = 998244353
a = []
i = 0
for ar in arr:
	a.append((ar, i))
	i += 1
a.sort(reverse=True)
res = 1
s = 0
ind = []
for i in range(k):
	s += a[i][0]
	ind.append(a[i][1])
ind.sort()
for i in range(1, k):
	diff = ind[i] - ind[i - 1]
	res = res % mod * (diff % mod) % mod
print(s, res % mod)


import sys, math
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	(n, k) = invr()
	a = inlt()
	q = 1
	w = 0
	qw = 0
	for i in range(len(a)):
		if a[i] >= n - k + 1:
			if qw == 1:
				q = q * (w + 1) % 998244353
			qw = 1
			w = 0
		else:
			w = w + 1
	print(n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2, q % 998244353)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ind = []
s = 0
for i in range(n):
	if l[i] > n - k:
		s += l[i]
		ind.append(i)
ln = len(ind)
ans = 1
for i in range(1, ln):
	temp = ind[i] - ind[i - 1]
	ans *= temp
print(s, ans % 998244353)


import sys

def main():
	(n, k) = [int(j) for j in sys.stdin.readline().split()]
	p = [int(j) for j in sys.stdin.readline().split()]
	ans1 = n * k - (k - 1) * k // 2
	last_occur = 0
	for i in range(n):
		if n - k + 1 <= p[i] <= n:
			last_occur = i
			break
	ans2 = 1
	for i in range(last_occur + 1, n):
		if n - k + 1 <= p[i] <= n:
			ans2 *= (i - last_occur) % 998244353
			last_occur = i
	print(ans1, ans2 % 998244353)
main()


(n, k) = [int(a) for a in input().split()]
sss = sum((a for a in range(n - k + 1, n + 1)))
permutation = [int(a) for a in input().split()]
diff = 1
line = n - k + 1
if k > 1:
	end = n - 1
	begin = 0
	while permutation[end] < line:
		end -= 1
	while permutation[begin] < line:
		begin += 1
	begin += 1
	while begin < end:
		cur_begin = begin
		while permutation[begin] < line:
			begin += 1
		begin += 1
		diff = diff * (begin - cur_begin) % 998244353
print('{0} {1}'.format(sss, diff))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
idx = []
j = 0
for i in l:
	if i > n - k:
		idx.append(j)
	j += 1
ans = 1
for i in range(k - 1):
	ans *= idx[i + 1] - idx[i]
	ans %= 998244353
mx = 0
for i in idx:
	mx += l[i]
print(mx, ans)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
P = list(map(int, input().split()))
mod = 998244353
Prev = [-1] * (n + 1)
for i in range(n):
	Prev[P[i]] = i
LAST = Prev[-k:]
LAST.sort()
ANS = 1
for i in range(1, len(LAST)):
	ANS = ANS * (LAST[i] - LAST[i - 1]) % mod
ANS2 = (n + (n - k + 1)) * k // 2
print(ANS2, ANS)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
max_list = [n - i for i in range(k)]
max_pos = []
for i in range(len(p)):
	if n - p[i] < k:
		max_pos.append(i)
c = 1
for i in range(len(max_pos) - 1):
	c = c * (max_pos[i + 1] - max_pos[i]) % 998244353
print(sum(max_list), c)


(n, k) = list(map(int, input().split()))
print((2 * n - k + 1) * k // 2, '', end='')
p = list(map(int, input().split()))
ind = []
num = 1
for i in range(n):
	if n - k + 1 <= p[i] <= n:
		ind.append(i)
for i in range(k - 1):
	num *= ind[i + 1] - ind[i]
print(num % 998244353)


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

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
(n, k) = R()
p = L()
print((2 * n - k + 1) * k // 2, end=' ')
last = -1
ans = 1
mod = 998244353
for i in range(n):
	if p[i] >= n - k + 1:
		if last != -1:
			ans *= i - last
			ans %= mod
		last = i
print(ans)


import os, sys
if os.path.exists('inp.txt'):
	sys.stdin = open('inp.txt', 'r')

def _():
	return sys.stdin.readline()

def __():
	return sys.stdin.readline().split()
maxn = 100005
a = [0 for i in range(maxn)]
mod = 998244353
(ok, ans, len, res) = (0, 0, 1, 1)
(n, k) = map(int, __())
a[1:] = list(map(int, __()))
for i in range(n, n - k, -1):
	ans += i
for i in range(1, n + 1):
	if ok:
		if a[i] >= n - k + 1:
			res *= len
			res %= mod
			len = 1
		else:
			len += 1
	elif a[i] >= n - k + 1:
		ok = 1
print(ans, res % mod)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
inde = []
su = 0
for j in range(n):
	if lst[j] >= n - k + 1:
		su += lst[j]
		inde.append(j)
x = 1
for r in range(len(inde) - 1):
	x *= inde[r + 1] - inde[r]
	x %= 998244353
print(su, x)


from collections import defaultdict
import math
from functools import reduce
mod = 998244353
su = 0
ans = 1
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
new = sorted([[arr[i], i] for i in range(n)], reverse=True)
idxs = []
for i in range(min(n, k)):
	su += new[i][0]
	idxs.append(new[i][1])
idxs.sort()
for i in range(1, len(idxs)):
	ans = ans % mod * ((idxs[i] - idxs[i - 1]) % mod)
	ans %= mod
print(su, ans)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
LL = [(L[i], i) for i in range(n)]
LL.sort(key=lambda x: x[0])
L = 0
for i in range(-k, 0):
	L += LL[i][0]
KK = sorted([LL[i][1] for i in range(-k, 0)])
A = 1
for i in range(1, k):
	A *= KK[i] - KK[i - 1]
	A %= 998244353
print(L, A)


m = 998244353
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = []
for i in range(n):
	if l[i] > n - k:
		p.append(i)
no = 1
for i in range(len(p) - 1):
	no = (p[i + 1] - p[i]) * no
sum = 0
for i in p:
	sum += l[i]
print(sum, end=' ')
print(no % m)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(n, k) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
mod = 998244353
if k == 1:
	print(n, 1)
else:
	l1 = [0 for i in range(n)]
	s = n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2
	for i in range(n):
		l1[l[i] - 1] = i
	l1 = sorted(l1[n - k:])
	prod = 1
	for i in range(1, k):
		prod = prod * (l1[i] - l1[i - 1]) % mod
	print(s, prod)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
mxs = sum(sorted(ls, reverse=True)[:k])
mxlim = n - k
ptr = 0
while ls[ptr] <= mxlim:
	ptr += 1
res = 1
runls = []
for i in range(k - 1):
	ptr += 1
	runlen = 1
	while ls[ptr] <= mxlim:
		ptr += 1
		runlen += 1
	runls.append(runlen)
	res *= runlen
	res %= 998244353
print(mxs, res)


from sys import stdin
mod = 998244353

def main():
	(n, k) = map(int, stdin.readline().split())
	p = list(map(int, stdin.readline().split()))
	P = [(-p[i], i) for i in range(n)]
	P.sort()
	Q = P[:k]
	Q.sort(key=lambda x: x[1])
	s = 0
	ans = 1
	for i in range(k):
		if i == 0:
			t = Q[i][1]
		else:
			ans *= Q[i][1] - t
			t = Q[i][1]
		s -= Q[i][0]
		ans %= mod
	print('{} {}'.format(s, ans))
main()


(N, K) = map(int, input().split())
L = list(map(int, input().split()))
MOD = 998244353
maximum = N * (N + 1) // 2 - (N - K) * (N - K + 1) // 2
used = set((v for v in range(N - K + 1, N + 1)))
seq_tmp = 0
used_cnt = 0
ans = 1
for v in L:
	if v in used:
		if seq_tmp == 0:
			pass
		elif used_cnt == 0:
			pass
		else:
			ans *= (seq_tmp + 1) % MOD
		seq_tmp = 0
		used_cnt += 1
	else:
		seq_tmp += 1
print(maximum, ans % MOD)


(n, k) = map(int, input().split())
mod = 998244353
templ = list(map(int, input().split()))
l = []
for i in range(n):
	l.append([templ[i], i])
summ = 0
l = sorted(l, key=lambda x: -x[0])
indices = []
for i in range(k):
	summ += l[i][0]
	indices.append(l[i][1])
indices.sort()
ans = 1
for i in range(0, k - 1):
	temp = ans % mod * (abs(indices[i] - indices[i + 1]) % mod) % mod
	ans = temp
print(str(summ) + ' ' + str(ans % mod))


import sys
from collections import defaultdict

def main():
	mod = 998244353

	def GCD(x, y):
		while y:
			(x, y) = (y, x % y)
		return x

	def lcm(a, b):
		return a * b // GCD(a, b)

	def merge(a, start, mid, end, d):
		p = start
		q = mid + 1
		arr = [0] * (end - start + 1)
		k = 0
		coun = 0
		for i in range(start, end + 1):
			if p > mid:
				arr[k] = a[q]
				q += 1
				k += 1
			elif q > end:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			elif a[p] < a[q]:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			else:
				arr[k] = a[q]
				k += 1
				q += 1
				coun += 1
		for i in range(k):
			a[start] = arr[i]
			start += 1

	def mergesort(a, start, end, d):
		if start < end:
			mid = (start + end) // 2
			mergesort(a, start, mid, d)
			mergesort(a, mid + 1, end, d)
			merge(a, start, mid, end, d)

	def inversion(l):
		d = {}
		for i in l:
			d[i] = 0
		mergesort(l, 0, len(l) - 1, d)
		return d

	def binary_search_lower(A, low, high, k):
		if high - low != 1:
			mid = (low + high) // 2
			x = A[mid]
			if x >= k:
				return binary_search_lower(A, low, mid, k)
			else:
				return binary_search_lower(A, mid, high, k)
		if A[low] >= k:
			return low
		else:
			return high

	def binary_expo(x, n):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return binary_expo(x * x, n // 2)
		else:
			return x * binary_expo(x * x, (n - 1) // 2)

	def modu_expo(x, n, m):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return modu_expo(x * x % m, n // 2, m)
		else:
			return x * modu_expo(x * x % m, (n - 1) // 2, m) % m

	def eEuclid(c, m):
		if m == 0:
			global d
			global x
			global y
			d = c
			x = 1
			y = 0
		else:
			eEuclid(m, c % m)
			temp = x
			x = y
			y = temp - c // m * y

	def mod_Inv(c, m):
		eEuclid(c, m)
		return (x % m + m) % m

	def ncr(n, r, p):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % p
			den = den * (i + 1) % p
		return num * pow(den, p - 2, p) % p
	(n, k) = map(int, sys.stdin.readline().split())
	l = [int(y) for y in sys.stdin.readline().split()]
	d = defaultdict(int)
	sum = 0
	for i in range(k):
		d[n - i] = 1
		sum += n - i
	ans = []
	for i in range(n):
		if d[l[i]] == 1:
			ans.append(i)
	c = 1
	for i in range(k - 1):
		c *= (ans[i + 1] - ans[i]) % mod
	print(sum, c % mod)
main()


import sys
from pprint import pprint
if not 'DEBUG' in globals():
	readline = sys.stdin.readline

def read(map_func):
	return map_func(readline().rstrip())

def reads(map_func):
	return list(map(map_func, readline().rstrip().split()))

def readn(map_func, n):
	return [read(map_func) for _ in range(n)]

def readint():
	return read(int)

def readints():
	return reads(int)

def readcol(n):
	return readn(int, n)

def readmat(n):
	return [readints() for _ in range(n)]

def readmap(n):
	return readn(list, n)

def makemat(n, m, v):
	return [[v] * m for _ in range(n)]

def zeromat(n, m=None):
	m = m if m else n
	return makemat(n, m, 0)

def listmat(n, m=None):
	m = m if m else n
	return [[[] for _ in range(m)] for _ in range(n)]

def crosslist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x), (y, x - 1), (y + 1, x)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def roundlist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x + 1), (y - 1, x), (y - 1, x - 1), (y, x - 1), (y + 1, x - 1), (y + 1, x), (y + 1, x + 1)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def plog(obj):
	pprint(obj) if 'DEBUG' in globals() else None

def log(msg, label=None):
	print((label + ': ' if label else '') + str(msg)) if 'DEBUG' in globals() else None

def _logmat(mat, label=None):
	fmt = '{:' + str(max((max((len(str(s)) for s in m)) for m in mat))) + 'd}'
	f = lambda row: '[' + ' '.join((fmt.format(x) for x in row)) + ']'
	[log('[' + f(row), label) if i == 0 else log((' ' * (len(label) + 3) if label else ' ') + f(row) + ']', None) if i == len(mat) - 1 else log((' ' * (len(label) + 3) if label else ' ') + f(row), None) for (i, row) in enumerate(mat)]

def logmat(mat, label=None):
	_logmat(mat, label) if 'DEBUG' in globals() else None
import math
from heapq import *
(n, k) = readints()
A = readints()
Q = []
for (i, a) in enumerate(A):
	heappush(Q, (-a, i))
P = []
r = 0
for _ in range(k):
	(x, i) = heappop(Q)
	r -= x
	heappush(P, i)
t = heappop(P)
s = 1
for _ in range(len(P)):
	x = heappop(P)
	s = s * (x - t) % 998244353
	t = x
print(r, s)


(n, k) = map(int, input().split(' '))
pos = [0] * (n + 1)
a = list(map(int, input().split(' ')))
for i in range(0, n):
	pos[a[i]] = i + 1
mx = 0
ans = 1
sr = []
for i in range(n, n - k, -1):
	mx += i
	sr.append(pos[i])
sr.sort()
for i in range(1, k):
	ans = ans * (sr[i] - sr[i - 1]) % 998244353
print(mx, ans)


MOD = 998244353
(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
temp = k
n2 = n
badeLog = set()
while k:
	badeLog.add(n)
	k -= 1
	n -= 1
indexes = []
for (ind, val) in enumerate(arr):
	if val in badeLog:
		indexes.append(ind)
ans = 1
for x in range(1, len(indexes)):
	ans = ans * (indexes[x] - indexes[x - 1]) % MOD
print(sum(badeLog), ans)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
(N, K) = MAP()
A = LIST()
border = N - K + 1
B = []
sm = 0
for (i, a) in enumerate(A):
	if a >= border:
		sm += a
		B.append(i)
C = []
for i in range(K - 1):
	C.append(B[i + 1] - B[i])
cnt = 1
for c in C:
	cnt *= c
	cnt %= MOD
print(sm, cnt)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = n - k
an = n * (n + 1) // 2 - x * (x + 1) // 2
rang = list(range(n, n - k, -1))
h = [0] * 1000000
for i in range(len(rang)):
	h[rang[i]] += 1
ans = []
pa = 1
m = 998244353
for i in range(n):
	if h[a[i]] == 1:
		ans.append(i)
for i in range(1, len(ans)):
	pa = pa % m * ((ans[i] - ans[i - 1]) % m)
print(an, pa % m)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = (arr[i], i)
arr.sort(reverse=True)
ans_sum = 0
inds = []
for i in range(k):
	inds.append(arr[i][1])
	ans_sum += arr[i][0]
inds.sort()
ans_num = 1
for i in range(k - 1):
	ans_num = ans_num * (inds[i + 1] - inds[i]) % 998244353
print(ans_sum, ans_num)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(n):
	c = (A[i], i)
	B.append(c)
B.sort()
B.reverse()
sm = 0
cnt = 1
C = []
for i in range(k):
	sm += B[i][0]
	C.append(B[i][1])
C.sort()
for i in range(k - 1):
	cnt = cnt * (C[i + 1] - C[i]) % 998244353
print(sm, cnt)


a = input().split()
n = int(a[0])
k = int(a[1])
lp = 0
i = 0
ans = 1
cnt = 0
a = input().split()
for ai in a:
	i = i + 1
	if int(ai) >= n - k + 1:
		if lp == 0:
			lp = i
		else:
			ans = ans * (i - lp)
			ans = ans % 998244353
			lp = i
		cnt = cnt + int(ai)
print(cnt, ans)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
ct = 0
a = sorted(b)
ans = sum(a[n - k:])
ans2 = 1
f = 0
mod = 998244353
for i in range(n):
	ct += 1
	if b[i] >= n - k + 1:
		if f:
			ans2 = ans2 * ct % mod
		ct = 0
		f = 1
print(ans, ans2)


import sys
import heapq
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
rw = lambda : sys.stdin.readline().strip()
(n, k) = RI()
a = RI()
h = []
heapq.heapify(h)
for i in range(k):
	heapq.heappush(h, [a[i], i])
for i in range(k, n):
	temp = heapq.heappushpop(h, [a[i], i])
arr = []
summ = 0
for i in range(k):
	temp = h[i]
	summ += temp[0]
	arr.append(temp[1])
arr.sort()
ans = 1
for i in range(1, k):
	prev = arr[i - 1]
	cur = arr[i]
	ans = ans * (cur - prev) % 998244353
print(summ, ans)


def solve(numbers, k):
	index = [i[0] for i in sorted(enumerate(numbers), key=lambda x: x[1], reverse=True)]
	su = 0
	se = set()
	for i in range(k):
		su += numbers[index[i]]
		se.add(index[i])
	curr = -1
	num = 1
	for i in range(len(numbers)):
		if curr != -1:
			curr += 1
		if i in se:
			curr -= 1
			if curr > -1:
				num *= curr + 1
			curr = 0
	return [str(su), str(num % 998244353)]
import random
nums = input().split(' ')
k = int(nums[1])
numbers = input().split(' ')
numbers = [int(i) for i in numbers]
print(' '.join(solve(numbers, k)))


(n, l) = [int(k) for k in input().split()]
arr = [int(k) for k in input().split()]
ind = {}
for i in range(len(arr)):
	ind[arr[i]] = i
ar = sorted(arr, reverse=True)
inds = []
for k in range(l):
	inds.append(ind[ar[k]])
inds.sort()
ans = 1
for s in range(1, l):
	ans = ans * (inds[s] - inds[s - 1]) % 998244353
print(sum(ar[:l]), ans)


[n, k] = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
najvacsie = set()
sucet = 0
for i in range(k):
	najvacsie.add(n - i)
	sucet += n - i
nasobime = []
indexy = []
for i in range(n):
	if p[i] in najvacsie:
		indexy.append(i)
moznosti = 1
for i in range(k - 1):
	moznosti = moznosti * (indexy[i + 1] - indexy[i]) % 998244353
print(sucet, moznosti)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
ind = []
for i in range(n):
	if L[i] > n - k:
		ind.append(i)
m = 1
for i in range(len(ind) - 1):
	m *= ind[i + 1] - ind[i]
	m %= 998244353
print(n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2, m)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
val = (2 * n - k + 1) * k // 2
MOD = 998244353
ans = 1
i = 0
while a[i] < n - k + 1:
	i += 1
prev = i
cntmax = 1
while cntmax < k:
	i += 1
	while a[i] < n - k + 1:
		i += 1
	ans = ans * (i - prev) % MOD
	prev = i
	cntmax += 1
print(val, ans)


MODULE = 998244353
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(range(n - k + 1, n + 1))
maxSum = sum(b)
sides = []
for i in range(len(a)):
	if a[i] >= n - k + 1 and a[i] <= n:
		sides.append(i)
answer = 1
for i in range(len(sides) - 1):
	answer *= sides[i + 1] - sides[i]
answer %= MODULE
print(maxSum, answer)


mod = 998244353
(n, k) = (int(o) for o in input().split())
a = [int(o) for o in input().split()]
for i in range(n):
	if a[i] <= n and a[i] > n - k:
		start = i
		break
for i in range(n - 1, -1, -1):
	if a[i] <= n and a[i] > n - k:
		end = i
		break
ans = 1
for i in range(start + 1, end + 1):
	if a[i] > n - k:
		ans *= i - start
		start = i
val = k * (n + n - k + 1) // 2
print(val, ans % mod)


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P, permutations as PERMUT
from bisect import bisect_left as BL, bisect_right as BR, insort as INSORT
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write
L = list
M = map

def Player1():
	print('')

def Player2():
	print('')

def Yes():
	PRINT('Yes\n')

def No():
	PRINT('No\n')

def IsPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def Factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def CheckPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def Sieve(n):
	prime = [1] * (n + 1)
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = 0
		p += 1
	primes = []
	for p in range(2, n + 1):
		if prime[p]:
			primes.append(p)
	return primes

def Prefix(a, n):
	p = []
	for i in range(n):
		if i == 0:
			p.append(a[0])
		else:
			p.append(p[-1] + a[i])
	return p

def Suffix(a, n):
	s = [0] * n
	for i in range(n - 1, -1, -1):
		if i == n - 1:
			s[i] = a[i]
		else:
			s[i] = s[i + 1] + a[i]
	return s

def Spf(n):
	spf = [0 for i in range(n)]
	spf[1] = 1
	for i in range(2, n):
		spf[i] = i
	for i in range(4, n, 2):
		spf[i] = 2
	for i in range(3, MC(SQRT(n)) + 1):
		if spf[i] == i:
			for j in range(i * i, n, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def Main():
	(n, k) = M(int, INPUT().split())
	p = L(M(int, INPUT().split()))
	index = []
	s = set()
	l = k
	mod = 998244353
	for i in range(n, 0, -1):
		if l:
			s.add(i)
			l -= 1
		else:
			break
	for i in range(n):
		if p[i] in s:
			index.append(i)
	ans = 0
	i = 0
	for v in index:
		ans += max(p[i:v + 1])
		i = v + 1
	res = 1
	for i in range(len(index) - 1):
		res = res % mod * (index[i + 1] - index[i]) % mod % mod
	PRINT('%d %d\n' % (ans, res))
Main()


(n, k) = map(int, input().split())
b_s = list(map(int, input().split()))
res1 = (2 * n - k + 1) * k // 2
ind = []
for i in range(len(b_s)):
	if n - k < b_s[i] <= n:
		ind.append(i)
res = 1
prev = ind[0]
for rr in range(1, len(ind)):
	res *= ind[rr] - prev
	prev = ind[rr]
	res = res % 998244353
print(res1, res)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
ok = 0
ret = 1
for i in range(n):
	if ok == 0:
		if a[i] > n - k:
			ok = 1
			cur = i
	elif a[i] > n - k:
		ret = ret * (i - cur) % 998244353
		cur = i
s = sum([x for x in range(n - k + 1, n + 1)])
print(s, end=' ')
print(ret)


import os
import sys
from io import BytesIO, IOBase
import threading
from math import floor
from collections import Counter
from math import gcd
mod = 998244353

def main():
	for _ in range(1):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		arr = list(zip(arr, range(0, n)))
		arr.sort(reverse=True)
		total = sum([i for (i, j) in arr[:k]])
		ind = [j for (i, j) in arr[:k]]
		ind.sort()
		ways = 1
		for i in range(1, len(ind)):
			ways = ways * (ind[i] - ind[i - 1]) % mod
		print(total, ways)
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')
main()


mod = 998244353

def main():
	(n, k) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	a = []
	for (i, ele) in enumerate(arr):
		a.append((ele, i))
	a.sort(key=lambda x: x[0], reverse=True)
	(b, s) = ([], 0)
	for i in range(k):
		s += a[i][0]
		b.append(a[i][1])
	b.sort()
	ret = 1
	for i in range(1, k):
		ret = ret * (b[i] - b[i - 1]) % mod
	print(s, ret)
main()


(n, k) = map(int, input().split())
mod = 998244353
ar = [int(x) for x in input().split()]
ans = 0
for p in range(n, n - k, -1):
	ans += p
temp = []
for p in range(n):
	if n - k + 1 <= ar[p]:
		temp.append(p + 1)
an = []
for p in range(1, k):
	an.append(temp[p] - temp[p - 1])
a = 1
for p in range(k - 1):
	a *= an[p]
	a %= mod
print(ans, a)


from sys import stdin
input = stdin.readline

def main():
	l = [int(i) for i in input().split(' ')]
	n = l[0]
	k = l[1]
	l = [int(i) for i in input().split(' ')]
	s = []
	ind = []
	for i in range(n):
		s.append([l[i], i])
	s.sort(reverse=True)
	val = 0
	for i in range(min(n, k)):
		val += s[i][0]
		ind.append(s[i][1])
	ind.sort()
	prod = 1
	for i in range(len(ind) - 1):
		prod *= ind[i + 1] - ind[i]
	print(val, prod % 998244353)
main()


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def dfs(u, lis):
	vis[u] = True
	lis.append(u)
	for v in g[u]:
		if not vis[v]:
			lis = dfs(v, lis)
	return lis

def dfsutil():
	cnc = []
	for i in range(1, n + 1):
		if not vis[i]:
			tmp = []
			cnc.append(dfs(i, tmp))
	return cnc

def bfs(s, prev):
	q = deque()
	q.append(s)
	vis[s] = True
	while q:
		u = q.popleft()
		for v in g[u]:
			if not vis[v]:
				q.append(v)
				vis[v] = True
				prev[v] = u

def path(s, e):
	prev = [False for i in range(n + 1)]
	bfs(s, prev)
	at = e
	res = []
	while at != False:
		res.append(at)
		at = prev[at]
	res.reverse()
	if res[0] == s:
		return res
	else:
		return []

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def ddd():
	return collections.defaultdict(collections.defaultdict(int))
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 = 998244353
(n, k) = mi()
a = li()
b = sorted(a, reverse=True)
d = dd()
for i in range(n):
	d[a[i]] = i
(sm, nm) = (0, [0 for i in range(k)])
for i in range(k):
	sm += b[i]
	nm[i] = d[b[i]]
nm.sort()
res = 1
for i in range(k - 1):
	res = res * ((nm[i + 1] - nm[i]) % mod) % mod
print(sm, res)


class Solution:

	def solve(self, n, k, a):
		a = sorted([[v, i] for (i, v) in enumerate(a)], reverse=True)[:k]
		k = sum([v for (v, _) in a])
		a = sorted([i for (_, i) in a])
		ans = 1
		mod = 998244353
		for i in range(1, len(a)):
			ans *= a[i] - a[i - 1]
			ans %= mod
		return (k, ans)

def main():
	inp = lambda : [int(x) for x in input().split()]
	(n, k) = inp()
	a = inp()
	a = Solution().solve(n, k, a)
	for i in a:
		print(i, end=' ')
	print()
main()


import sys
input = sys.stdin.readline
(x, y) = map(int, input().split())
(*li,) = map(int, input().split())
if x == y:
	print(sum(li), 1)
	exit()
flag = False
cnt = 0
ans = 1
for i in li:
	if i > x - y:
		if flag:
			ans *= cnt + 1
			ans %= 998244353
			cnt = 0
		else:
			flag = True
			cnt = 0
	else:
		cnt += 1
n = x - y
print(x * (x + 1) // 2 - n * (n + 1) // 2, ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
maxi = k * (2 * n - k + 1) // 2
c = []
for i in range(n):
	x = a[i]
	if x > n - k:
		c.append(i)
c.sort()
total = 1
for i in range(1, len(c)):
	total *= c[i] - c[i - 1]
print(maxi, total % 998244353)


(n, k) = [*map(int, input().split())]
p = [*map(int, input().split())]
ind = sorted(sorted(range(len(p)), key=lambda i: p[i])[-k:])
s = sum([p[i] for i in ind])
pr = 1
for i in range(1, len(ind)):
	pr = pr * (ind[i] - ind[i - 1]) % 998244353
print(s, pr, sep=' ', end='')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, K, P):
	MOD = 998244353
	mx = 0
	for i in range(K):
		mx += N - i
	ans = 1
	last = None
	for (i, p) in enumerate(P):
		if p > N - K:
			if last is not None:
				ans *= i - last
				ans %= MOD
			last = i
	return str(mx) + ' ' + str(ans)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, K) = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
ans = solve(N, K, P)
print(ans)


temp = [int(x) for x in input().split()]
n = temp[0]
k = temp[1]
arr = [(int(x), i) for (i, x) in enumerate(input().split())]
arr.sort(reverse=True)
mod = 998244353
index = list(map(lambda item: item[1], arr[:k]))
items = map(lambda item: item[0], arr[:k])
index.sort()
sol = 1
for i in range(len(index) - 1):
	sol *= index[i + 1] - index[i]
	sol %= mod
print(sum(items), sol, sep=' ')


import sys
input = sys.stdin.buffer.readline
(a, b) = list(map(int, input().split()))
l = list(map(int, input().split()))
mod = 998244353
nums = []
c = 0
z = a - b + 1
for i in range(a):
	if l[i] < z:
		c += 1
	else:
		nums.append(c + 1)
		c = 0
ans = 1
for i in range(1, len(nums)):
	ans *= nums[i]
	ans = ans % mod
tot = (a - (b - 1) / 2) * b
print(int(tot), ans)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, k) = iia()
arr = iia()
thres = n - k + 1
pos = []
summ = 0
for (j, i) in enumerate(arr):
	if i >= thres:
		pos.append(j)
		summ += i
res = 1
for i in range(1, len(pos)):
	res *= pos[i] - pos[i - 1]
print(summ, res % 998244353)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
mod = 998244353
for i in range(n - k + 1, n + 1):
	ans += i
print(ans)
for i in range(n):
	if p[i] >= n - k + 1:
		l = i
		break
current = 1
ans = 1
for i in range(l, n):
	if p[i] >= n - k + 1:
		ans = ans * current % mod
		current = 1
	else:
		current += 1
print(ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
x = 0
y = 1
mod = 998244353
a = []
for i in range(n):
	if p[i] > n - k:
		x += p[i]
		a.append(i + 1)
for i in range(k - 1):
	y *= a[i + 1] - a[i]
print(x, y % mod)


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	(n, k) = RL()
	arr = list(RL())
	mod = 998244353
	ns = sorted(arr, reverse=1)
	res = sum(ns[:k])
	cp = set(ns[:k])
	num = -1
	rnum = 1
	for (i, v) in enumerate(arr):
		if v in cp:
			pre = i - num - 1
			if num != -1:
				rnum = rnum * (pre + 1)
			num = i
	print(res, rnum % mod)
main()


def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = arr.copy()
ind = dict()
for i in range(len(l)):
	ind[arr[i]] = i
l.sort()
ind1 = []
l = l[::-1]
for i in range(k):
	ind1.append(ind[l[i]])
aa = sum(l[:k])
if n == k:
	print(aa, 1)
else:
	ind1.sort()
	ans = 1
	for i in range(0, len(ind1) - 1):
		ans = ans % 998244353 * ((ind1[i + 1] - ind1[i]) % 998244353) % 998244353
	print(aa, ans % 998244353)


mod = 998244353
(n, k) = map(int, input().split())
s = n - k + 1
P = list(map(int, input().split()))
ans1 = (2 * n - k + 1) * k // 2
ans2 = 1
l = []
for i in range(n):
	if P[i] >= s:
		l.append(i)
for i in range(len(l) - 1):
	ans2 = ans2 * (l[i + 1] - l[i]) % mod
print(ans1, ans2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n, n - k, -1):
	s = s + i
(minimum, maximum) = (n - k + 1, n)
(count, total_partition) = (0, 1)
for i in range(n):
	if a[i] <= maximum and a[i] >= minimum:
		j = i
		break
for i in range(j, n):
	if a[i] <= maximum and a[i] >= minimum:
		count = count + 1
		total_partition = total_partition * count % 998244353
		count = 0
	else:
		count = count + 1
print(s, total_partition)


import math, sys
import heapq
from fractions import Fraction
from collections import Counter, defaultdict

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

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def dic(x):
	return defaultdict(lambda : x)

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def binarySearch(arr, x):
	(l, r) = (0, len(arr) - 1)
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return True
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return False
(n, k) = li()
a = li()
index = []
total = 0
for i in range(n):
	if a[i] >= n - k + 1:
		total += a[i]
		index.append(i)
num = 1
for i in range(1, len(index)):
	num *= index[i] - index[i - 1]
print(total, num % 998244353)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
prev = -1
sum = 0
ans = 1
for (ind, i) in enumerate(s):
	if i >= n - k + 1:
		if prev != -1:
			ans *= ind - prev
		prev = ind
		sum += i
print(sum, ans % 998244353)