#!/usr/bin/env python # -*- coding: utf-8 -*- N,K = map(int,input().split()) A = list(map(int,input().split())) dp = [A[i] if i < N else False for i in range(10**6+1)] dp[N] = sum(dp[:N]) for i in range(N+1,K+1): dp[i] = dp[i-1] *2 - dp[i-N-1] print(dp[K-1],sum(dp[:K]))