import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Round_213_Div1 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int d = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (max + d >= data[i]) {
                max += data[i];
            }
        }
        boolean[] dp = new boolean[max + 1];
        dp[0] = true;
        TreeSet<Integer> set = new TreeSet();
        set.add(0);
        for (int i = 0; i < n; i++) {
            for (int j = max; j >= 0; j--) {
                if (dp[j] && j + data[i] <= max) {
                    set.add(j + data[i]);
                    dp[j +  data[i]]  = true;
                }
            }
        }
        //System.out.println("HE HE" + " " + set + " " + max);
        int start = 0;
        int c = 0;
        while (start < max) {
            int v = Math.min(start + d, max);
            start = set.floor(v);
           // System.out.println(start);
            c++;
        }
        out.println(max + " " + c);

        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Round_213_Div1 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int d = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (max + d >= data[i]) {
                max += data[i];
            }
        }
        int v = cal(max, 0, d, new boolean[n], data);
        out.println(max + " " + v);
        out.close();
    }

    public static int cal(int max, int have, int d, boolean[] taken, int[] data) {
        if (max == have) {
            return 0;
        }
        int left = max - have;
        int[] a = new int[max + 1];
        int[] b = new int[max + 1];
        Arrays.fill(a, -1);
        Arrays.fill(b, -1);
        TreeSet<Integer> set = new TreeSet();
        TreeSet<Integer> o = new TreeSet();
        set.add(0);
        o.add(0);
        for (int i = 0; i < data.length; i++) {
            TreeSet<Integer> tmp1 = new TreeSet();
            TreeSet<Integer> tmp2 = new TreeSet();
            if (taken[i]) {
                for (int j : set) {
                    if ( j + data[i] <= max && a[j + data[i]] == -1) {
                        a[j + data[i]] = i;
                        tmp1.add(j + data[i]);
                    }
                }
            } else {
                for (int j : o) {
                    if (j + data[i] <= max && b[j + data[i]] == -1) {
                        b[j + data[i]] = i;
                        tmp2.add(j + data[i]);
                    }
                }
            }
            set.addAll(tmp1);
            o.addAll(tmp2);
        }
        //System.out.println(Arrays.toString(b) + " " + set);
        int cur = 0;
        int result = -1;
        int other = 0;
        for (int i = max; i >= 0; i--) {
            if (b[i] != -1) {
                Integer v = set.ceiling(i - d);

                if (v != null) {

                    int tmp = have - v + i;
                    if (tmp > cur) {
                        cur = tmp;
                        other = v;
                        result = i;
                    }
                }
            }
        }
       // System.out.println(cur + " " + other + " " + result + " " + d);
        while (result > 0) {
            taken[b[result]] = true;
            result -= data[b[result]];
           // System.out.println(result);
        }
        while (other > 0) {
            taken[a[other]] = false;
            other -= data[a[other]];

        }

        return 1 + cal(max, cur, d, taken, data);

    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


2 3 3import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by zephyr on 10/16/14.
 */
public class Runner {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long[] values = new long[3];
        for (int i = 0; i < 3; i++) {
            values[i] = scanner.nextLong();
        }
        long total = 0;
        Arrays.sort(values);
        if (values[2] > 2* (values[0] + values[1])){
            total = values[0] + values[1];
        }else{
            total  = (values[0] + values[1] + values[2])/3;
        }
        System.out.println(total);
    }

}


import java.util.*;

public class C478{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long a[] = new int[3];
		a[0] = in.nextLong();
		a[1] = in.nextLong();
		a[2] = in.nextLong();

		Arrays.sort(a);
		a[1] = a[1]-a[0];
		a[2] = a[2]-a[0];

		long tmp=a[1]/3;
		a[0]+=2*tmp;
		a[1] = a[1]%3;
		a[2] -= tmp*3;

		if(a[1]>=1 && a[2]>1){
			a[0]+=1;
		}
		System.out.println(a[0]);

	}
}


import java.util.*;
import java.io.*;

public class Class{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int r = Integer.parseInt(st.nextToken());
        int g = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int sum = 0;
        while(r+g+b>2){
            int max, mid, min;
            if(r>=g&&g>=b){max = r; mid = g; min = b;}
            else if(r>=b&&b>=g){max = r; mid = b; min = g;}
            else if(b>=r&&r>=g){max = b; mid = r; min = g;}
            else if(b>=g&&g>=r){max = b; mid = g; min = r;}
            else if(g>=r&&r>=b){max = g; mid = r; min = b;}
            else if(g>=b&&b>=r){max = g; mid = b; min = r;}
            r = max; g = mid; b = min;

            if(r==g&&g==b){sum+=r; break;}
            else{sum++; r-=2; g--;}
        }
        System.out.print(sum);
    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[]=new int[3];
		for(int i=0;i<3;i++){
		    A[i]=sc.nextInt();
		}
		Arrays.sort(A);
		int m = A[0]+A[1];
		if(A[2]<m*2){
		    System.out.println((m+A[2])/3);
		}else{
		    System.out.println(m)
		}

	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author ADMIN
 */import java.util.*;
public class cf916A {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s=new Scanner(System.in);
        int x=s.nextInt();
        int hh=s.nextInt();
        int mm=s.nextInt();
        int snooze=0;
        while(hh!=0 || mm!=0){
             if(hh%10==7 || mm%10==7)
                break;
             if (mm < x) {
                mm = (mm + 60 - x);
                hh=(hh==0)?hh=23:--h;
               /* if(hh==0)
                    hh=23;

                else
                    --hh;*/

            } else {
                mm -= x;
            }

         snooze++;

        }
        System.out.println(snooze);
    }

}


import java.util.Scanner;

public class A916 {
	public static void main(String s[]) throws IOException {
		Scanner sc = new Scanner(System.in);
		Integer snooze = sc.nextInt();
		Integer hh = sc.nextInt();
		Integer mm = sc.nextInt();
		Integer count=0;
		String full = hh.toString() + mm.toString();
		while(!full.contains("7")) {
			//System.out.println("In While");
			if((mm-snooze)>0) {
				mm-=snooze;
				count++;
			}
			else {
				if((hh-1)>0) {
					hh=23;
				}
				else {
					hh-=1;
				}
				mm=60-snooze+mm;
				count++;
			}
			full = hh.toString() + mm.toString();
		}
		System.out.println(count);

	}
}


import java.util.*;
import java.io.*;

public class 916A{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int curr = h*60 + m , flag = 0;

        while(curr > 0){
            curr = curr - x;
            if(contains(curr) == true){
                flag = 1;
                break;
            }
        }

        if(flag == 0){
            curr = 23*60 + 59;
            while(curr > 0){
            curr = curr - x;
            if(contains(curr) == true){
                flag = 1;
                break;
            }
        }
        }
        System.out.println(curr);
    }
}


import java.util.*;
public class Main {
  public static void main(String[] args) {
    //System.out.println("Hello world!");
    Scanner s=new Scanner(System.in);
    int v=s.nextInt();
    int hh=s.nextInt();
    int mm=s.nextInt();
    if(hh%10==7||mm%10==7)
      System.out.println(0);
    else
    {
      int c=0;
      while(hh%10!=7&&mm%10!=7)
      {
      if(v>mm)
      {
        m=60-(v-mm);
        if(h==0)
        hh=23;
        else
        hh-=1;
      }
      else
      mm-=v;
      c++;
      }
      System.out.println(c);
    }
  }
}


import java.io.*;
import java.util.*;
public class Solution
{
    public static void main(String args[])
    {

    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int sum=a+b+c;

    if(sum % 2 == 0)
    {
        sum /= 2;
        int x = sum - c;
        int y = sum - a;
        int z = sum - b;

        if(x >= 0 && y >= 0 && z >= 0)
            System.out.println("%d %d %d\n", x, y, z);
        else
            System.out.println("Impossible");
    }
    else
        System.out.println("Impossible");

}
}


import java.util.*;
import java.lang.Math.*;
public class q4
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a[]=new int[3];
		for(int i=0;i<3;i++)
			a[i]=sc.nextInt();
		int x=(a[0]+a[1]-a[2])/2;
		int y=(a[1]+a[2]-a[0])/2;
		int z=(a[2]+a[0]-a[1])/2;
		//if(x<0||y<0||z<0)
		//	System.out.println("Impossible");
		else
		{
			System.out.println(x);
			System.out.println(y);
			System.out.println(z);
		}

	}
}


import java.util.*;
import java.lang.Math;
import java.lang.Object;
import java.text.DecimalFormat;
public class test{

    public static void main(String args[])

{
    Scanner in= new Scanner(System.in);
     int n,count=0,f=0,i;
     double x,y,z;
     int a,b,c;
     a=in.nextInt();
     b=in.nextInt();
     c=in.nextInt();
     z=(a+b-c)/2;
     y=(b+c-a)/2;
     x=(a+c-b)/2;
     if((x==(int)x&&y==(int)y&&z==(int)z)&&x=>0&&y=>0&&z=>0)
     {
        System.out.println((int)z+" "+(int)y+" "+(int)x);
     }
     else
        System.out.println("Impossible");

    }

}


import java.io.*;
import java.util.*;
public class Solution
{
    public static void main(String args[])
    {

    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int sum=a+b+c;

    if(sum % 2 == 0)
    {
        sum /= 2;
        int x = sum - c;
        int y = sum - a;
        int z = sum - b;

        if(x >= 0 && y >= 0 && z >= 0)
            System.out.println("%d %d %d\n", x, y, z);
        else
            System.out.println("Impossible");
    }
    else
        System.out.println("Impossible");

}


import java.io.*;
import java.util.*;

public class HarryPotterAndThreeSpells {
    import java.io.*;
import java.util.*;

public class HarryPotterAndThreeSpells {
    public static void main(String[] args) throws IOException {
        BufferedReader ff = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(ff.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int e = Integer.parseInt(st.nextToken());
        int f = Integer.parseInt(st.nextToken());
        if ((a == 0 && b > 0 && d > 0) || (c == 0 && d > 0) || b*d*f > a*c*e)
            System.out.println("Ron");
        else
            System.out.println("Hermione");
    }
}public static void main(String[] args) throws IOException {
        BufferedReader ff = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(ff.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int e = Integer.parseInt(st.nextToken());
        int f = Integer.parseInt(st.nextToken());
        if ((c == 0 && d > 0) || b*d*f > a*c*e)
            System.out.println("Ron");
        else
            System.out.println("Hermione");
    }
}


public class R65A {
	static String handle(int[] nums) {
		if (nums[2] == 0 && nums[3] > 0)
			return "Ron";
		if (nums[1] == 0 || nums[3] == 0 || nums[5] == 0)
			return "Hermione";
		if (nums[0] == 0 || nums[2] == 0 || nums[4] == 0)
			return "Ron";
		if (1.0 * nums[1] * nums[3] * nums[5] / nums[0] / nums[2] / nums[4] > 1)
			return "Ron";
		return "Hermione";
	}

	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		int[] nums = new int[6];
		for (int i = 0; i < nums.length; i++) {
			nums[i] = s.nextInt();
		}
		String result = handle(nums);
		System.out.println(result);
	}
}


import java.io.*;
import java.util.*;

public class HarryPotterAndThreeSpells {
    public static void main(String[] args) throws IOException {
        BufferedReader ff = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(ff.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int e = Integer.parseInt(st.nextToken());
        int f = Integer.parseInt(st.nextToken());
        if ((c == 0 && d > 0) || b*d*f > a*c*e)
            System.out.println("Ron");
        else
            System.out.println("Hermione");
    }
}import java.io.*;
import java.util.*;

public class HarryPotterAndThreeSpells {
    public static void main(String[] args) throws IOException {
        BufferedReader ff = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(ff.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int e = Integer.parseInt(st.nextToken());
        int f = Integer.parseInt(st.nextToken());
        if (b*d*f > a*c*e)
            System.out.println("Ron");
        else
            System.out.println("Hermione");
    }
}


import java.io.*;
import java.util.*;

public class A {

    MyScanner in;
    PrintWriter out;

    public static void main(String[] args) throws Exception {
        new A().run();
    }

    public void run() throws Exception {
        in = new MyScanner();
        out = new PrintWriter(System.out);

        out.println(solve());

        out.close();
    }

    public String solve() throws Exception {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        int e = in.nextInt();
        int f = in.nextInt();

        if (a + b + c + d + e + f == 0) {
            return "Hermione";
        } else if ((c == 0) && (d != 0)) {
            return "Ron";
        } else if ((a == 0) && (b != 0) && (d != 0)) {
            return "Ron";
        }
        if (b * d * f > a * c * e) {
            return "Ron";
        } else {
            return "Hermione"
        }
    }
}

class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() throws Exception {
        if ((st == null) || (!st.hasMoreTokens())) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws Exception {
        return Integer.parseInt(next());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }

    boolean nextBoolean() throws Exception {
        return Boolean.parseBoolean(next());
    }

    long nextLong() throws Exception {
        return Long.parseLong(next());
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
      Scanner in= new Scanner(System.in);
      long a= in.nextLong(), b= in.nextLong();
      String s1= binary(a), s2= binary(b);
      String reverse= (new StringBuilder(s1).reverse()).toString();
      if(check(s1,s2) || check(reverse,s2)) System.out.println("YES");
      else System.out.println("NO");

    }
    private static String binary(long a){
        String res="";
        while(a>0){
            res= (a%2)+res;
            a/=2;
        }
        return res;
    }
    private static boolean check(String s1, String s2){
        int l=0, r= s1.length()-1;
        while(l<s1.length()){
            if(s1.charAt(l)=='1') break;
            l++;
        }
        while(r>=l){
            if(s1.charAt(r)=='1') break;
            r--;
        }
        s1= s1.substring(l,r+1);
        l= s2.indexOf(s1);
        if(l==-1) return false;
        r= l+s1.length();
        if(r<s2.length()){
            if(s2.charAt(s2.length()-1)=='0') return false;
        }
        return true;

    }

}


/*
        "Everything in the universe is balanced. Every disappointment
                you face in life will be balanced by something good for you!
                        Keep going, never give up."

*/

import java.util.*;
import java.lang.*;
import java.io.*;

public class Solution {
    public static void main(String[] args) throws java.lang.Exception {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new FastReader();

        int test = sc.nextInt();
        for (int t = 0; t < test; t++) {
            solve();
        }
        out.close();
    }

    private static void solve() {
        long x = sc.nextLong();
        long y = sc.nextLong();
        Set<String> visited = new HashSet<>();
        Queue<String> q = new LinkedList<>();
        String num = Long.toBinaryString(x);
        q.add(num);
        visited.add(num);
        while (!q.isEmpty()) {
            String now = q.poll();
            if (now.length() > 100) {
                continue;
            }
            for (int i = 0; i < 2; i++) {
                // append i to curr
                String curr = now + (char) ('0' + i);
                curr = update(curr);
                if (!visited.contains(curr)) {
                    visited.add(curr);
                    q.add(curr);
                }
            }
        }
        String want = Long.toBinaryString(y);
        if (visited.contains(want)) {
            out.println("YES");
        }else {
            out.println("NO");
        }
    }

    private static String update(String curr) {
        while (curr.charAt(curr.length() - 1) == '0') {
            curr = curr.substring(0, curr.length() - 1);
        }
        StringBuilder res = new StringBuilder(curr);
        return res.reverse().toString();
    }

    public static FastReader sc;
    public static PrintWriter out;
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer str;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (str == null || !str.hasMoreElements())
            {
                try
                {
                    str = new StringTokenizer(br.readLine());
                }
                catch (IOException  end)
                {
                    end.printStackTrace();
                }
            }
            return str.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException end)
            {
                end.printStackTrace();
            }
            return str;
        }
    }
}


// package c1618;

import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.Random;
import java.util.Scanner;

//
// Codeforces Round #760 (Div. 3) 2021-12-14 06:35
// F. Reverse
// https://codeforces.com/contest/1618/problem/F
// time limit per test 2 seconds; memory limit per test 256 megabytes
// public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class\s+(\w+).*'
//
// You are given two positive integers x and y. You can perform the following operation with x:
// write it in its binary form without leading zeros, add 0 or 1 to the right of it, reverse the
// binary form and turn it into a decimal number which is assigned as the new value of x.
//
// For example:
//  * 34 can be turned into 81 via one operation: the binary form of 34 is 100010, if you add 1,
//    reverse it and remove leading zeros, you will get 1010001, which is the binary form of 81.
//  * 34 can be turned into 17 via one operation: the binary form of 34 is 100010, if you add 0,
//    reverse it and remove leading zeros, you will get 10001, which is the binary form of 17.
//  * 81 can be turned into 69 via one operation: the binary form of 81 is 1010001, if you add 0,
//    reverse it and remove leading zeros, you will get 1000101, which is the binary form of 69.
//  * 34 can be turned into 69 via two operations: first you turn 34 into 81 and then 81 into 69.
//
// Your task is to find out whether x can be turned into y after a certain number of operations
// (possibly zero).
//
// Input
//
// The only line of the input contains two integers x and y (1 <= x, y <= 10^{18}).
//
// Output
//
// Print if you can make x equal to y and if you can't.
//
// Example
/*
input:
3 3

output:
YES

input:
7 4

output:
NO

input:
2 8

output:
NO

input:
34 69

output:
YES

input:
8935891487501725 71487131900013807

output:
YES
*/
// Note
//
// In the first example, you don't even need to do anything.
//
// The fourth example is described in the statement.
//
public class C1618F {
  static final int MOD = (int)1e9+7;
  static final Random RAND = new Random();

  static boolean solveInner(long x, long y) {
    // when x is odd:
    //     x                   y1                  y2
    // 00: abcd -> abcd0 ->  dcba ->  dcba0 ->   abcd
    // 01: abcd -> abcd0 ->  dcba ->  dcba1 ->  1abcd
    // 10: abcd -> abcd1 -> 1dcba -> 1dcba0 ->  abcd1
    // 11: abcd -> abcd1 -> 1dcba -> 1dcba1 -> 1abcd1

    String sx = Long.toBinaryString(x);
    String sy = Long.toBinaryString(y);
    String rx = new StringBuilder(sx).reverse().toString();
    if (x % 2 == 1) {
      return isOkXOdd(sx, sy, rx);
    } else {
      long core = x;
      while (core % 2 == 0) {
        core >>= 1;
      }
      String cx = Long.toBinaryString(core);
      String rcx = new StringBuilder(cx).reverse().toString();
      return isOkXEven(sx, sy, rx, cx, rcx);
    }
  }

  // when x is odd:
  //     x                   y1                  y2
  // 00: abcd -> abcd0 ->  dcba ->  dcba0 ->   abcd
  // 01: abcd -> abcd0 ->  dcba ->  dcba1 ->  1abcd
  // 10: abcd -> abcd1 -> 1dcba -> 1dcba0 ->  abcd1
  // 11: abcd -> abcd1 -> 1dcba -> 1dcba1 -> 1abcd1
  static boolean isOkXOdd(String x, String y, String rx) {
    int n = y.length();
    if (y.equals(x) || y.equals(rx) || y.substring(1).equals(rx)) {
      return true;
    }
    if (y.length() < x.length()) {
      return false;
    }
    if (isOkXOdd(x, y.substring(1), rx)) {
      return true;
    }
    if (y.charAt(n-1) == '1') {
      if (isOkXOdd(x, y.substring(0, n-1), rx)) {
        return true;
      }
      if (n > 1 && isOkXOdd(x, y.substring(1, n-1), rx)) {
        return true;
      }
    }
    return false;
  }

  // when x is even:
  //     x                      y1                    y2
  // 00: abc00 -> abc000 ->    cba ->    cba0 ->     abc
  // 01: abc00 -> abc000 ->    cba ->    cba1 ->    1abc
  // 10: abc00 -> abc001 -> 100cba -> 100cba0 ->  abc001
  // 11: abc00 -> abc001 -> 100cba -> 100cba1 -> 1abc001
  static boolean isOkXEven(String x, String y, String rx, String cx, String rcx) {
    int n = y.length();
    if (y.equals(x) || y.equals(rcx) || y.equals(cx)
        || y.substring(1).equals(cx) || y.substring(1).equals(rx)) {
      return true;
    }
    if (y.length() < cx.length()) {
      return false;
    }
    if (isOkXEven(x, y.substring(1), rx, cx, rcx)) {
      return true;
    }
    if (y.charAt(n-1) == '1') {
      if (isOkXEven(x, y.substring(0, n-1), rx, cx, rcx)) {
        return true;
      }
      if (n > 1 && isOkXEven(x, y.substring(1, n-1), rx, cx, rcx)) {
        return true;
      }
    }
    return false;
  }

  static void solve(long x, long y) {
    boolean ans = solveInner(x, y);
    System.out.println(ans ? "YES" : "NO");
  }

  static void doTest() {
    solve(3, 3);
    solve(7, 4);
    solve(2, 8);
    solve(34, 69);
    solve(8935891487501725L, 71487131900013807L);
    solve(26, 11);
    solve(Integer.parseInt("110100", 2), Integer.parseInt("1101", 2));
    System.exit(0);
  }

  public static void main(String[] args) {
    // doTest();
    Scanner in = getInputScanner();
    long x = in.nextLong();
    long y = in.nextLong();
    solve(x, y);
    in.close();
  }

  static Scanner getInputScanner() {
    try {
      final String USERDIR = System.getProperty("user.dir");
      final String CNAME = MethodHandles.lookup().lookupClass().getSimpleName();
      final File fin = new File(USERDIR + "/io/c" + CNAME.substring(1,5) + "/" + CNAME + ".in");
      return fin.exists() ? new Scanner(fin) : new Scanner(System.in);
    } catch (Exception e) {
      return new Scanner(System.in);
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF1 {
    public static void main(String[] args) {
        FastScanner sc=new FastScanner();
        int T=sc.nextInt();
//        int T=1;
        for (int tt=0; tt<T; tt++){
            int n = sc.nextInt();
            long sum=0L;
            int arr[]= sc.readArray(n);
            for (int i=0; i<n; i++){
                sum+=arr[i];
            }
            boolean possible =true;
            long y=(long)((long)n*(long)(n+1))/2;
            if (sum%y!=0) possible=false;
            sum/=y;

//            if (sum<n)

            int ans[]= new int [n];
            for (int i=0; i<n-1; i++){
                int x=arr[i]+(int)sum-arr[i+1];
                if (x<=0 || x%n!=0) {
                    possible=false;
                    break;
                }
                else ans[i+1]=x/n;
            }
            int x =arr[n-1]+(int)sum-arr[0];
            if (x<=0 || x%n!=0) {
                possible=false;

            }
            else ans[0]=x/n;
            if (possible){
                System.out.println("YES");
                StringBuilder sb= new StringBuilder();
                for (int i=0; i<n; i++){
                    sb.append(ans[i]+" ");
                }
                System.out.println(sb.toString());
            }
            else System.out.println("NO");
        }
// arr[i+1]= arr[0]+sum-n*x;
    }
    static boolean help(char arr[], int start, int end){
        for (int i=start+1; i<end; i++){
            if (arr[i]=='b' && arr[i-1]=='a' && arr[i+1]=='c') return true;
        }
        return false;
    }
    static long mod =998244353L;
    static long power (long a, long b){
        long res=1;
        while (b>0){
            if ((b&1)== 1){
                res= (res * a % mod)%mod;
            }
            a=(a%mod * a%mod)%mod;
            b=b>>1;
        }
        return res;
    }
    boolean[] sieveOfEratosthenes(int n)
    {

        boolean prime[] = new boolean[n+1];
        for(int i=0;i<=n;i++)
            prime[i] = true;

        for(int p = 2; p*p <=n; p++)
        {
            if(prime[p] == true)
            {
                for(int i = p*p; i <= n; i += p)
                    prime[i] = false;
            }
        }
        return prime;
    }
    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortLong(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static long gcd (long n, long m){
        if (m==0) return n;
        else return gcd(m, n%m);
    }
    static class Pair{
        int x,y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
    }
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


import java.io.*;
public class Solution {
public static void main (String []args) throws IOException {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
args = br.readLine().split(" ");
int [] ns = new int [3];
ns[0] = Integer.parseInt(args[0]);
ns[1] = Integer.parseInt(args[1]);
ns[2] = Integer.parseInt(args[2]);
int max = Math.max(ns[0], ns[1]);
max = Math.max(max, ns[2]);
int maxIndex = (max == ns[2]) ? 2 : ((max == ns[1]) ? 1 : 0);
int rounds = Math.ceil(max / 2);
int res = (max == 0) ? 0 : 30 + (rounds - 1) * 3 + maxIndex;
System.out.println(res);
}
}


import java.util.Scanner;

public class Main {

void go()
    {Scanner s=new Scanner(System.in);
int r=s.nextInt();int g=s.nextInt();int b=s.nextInt();
int time=-1;
if(r==0&&g==0&&b==0)
{time++;
 System.out.println(time);
break();
}
while(r>0||g>0||b>0)

{
    if(r>0)
    {r-=2;time++;}else if(g>0||b>0){time++;}
    if(g>0)
    {g-=2;time++;}else if(b>0){time++;}
if(b>0)
    {b-=2;time++;}

}time+=30;
     System.out.println(time);
}

    public static void main(String[] args) {

Main m=new Main();
m.go();

}
}


import net.egork.utils.test.Test;
import java.util.Collection;
import net.egork.utils.Exit;
import net.egork.utils.io.StreamInputReader;
import java.io.*;
import net.egork.utils.io.InputReader;
import net.egork.utils.Solver;
public class Main {
	public static void main(String[] args) {
		InputReader in = new StreamInputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		run(in, out);
	}

	public static void run(InputReader in, PrintWriter out) {
		Solver solver = new TaskA();
		solver.solve(1, in, out);
		Exit.exit(in, out);
	}
}

class MainChecker {
	public static String check(InputReader input, InputReader expectedOutput, InputReader actualOutput) {
		return new TaskAChecker().check(input, expectedOutput, actualOutput);
	}

	public static Collection<Test> generateTests() {
		return new TaskAChecker().generateTests();
	}
}


import java.util.Scanner;

/**
 *
 * @author Тимур
 */
public class JavaApplication24 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //||\\ TODO code application logic here
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        int g = in.nextInt();
        int b = in.nextInt();
        int time = 0;
        for (int i = 0; true; i++) {
            if (r > 0) {
                r = r - 2;

            }
            if (r <=0&& g<=0&&b<=0) {
                break;
            }
            time = time + 1;
            if (g > 0) {
                g = g - 2;
            }
            if (r <=0&& g<=0&&b<=0) {
                break;
            }
            time = time + 1;
            if (b > 0) {
                b = b - 2;
            }
            if (r <=0&& g<=0&&b<=0) {
                break;
            }
            time = time + 1;

        }
        System.out.print(time + 30);

    }

}
]


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	public void solve() throws Exception {
		long r = sc.nextInt(), h = sc.nextInt();
		r *= 2;
		h *= 2;
		long n = (h + r / 2) / r;
		if (n == 0) {
			out.println(1);
		} else {
			long hmax = n * r - r / 2;
			long left = h + r - hmax;
			long ans = 2 * n;
			if (r * r * 3 <= (left - r / 2) * (left - r / 2) * 4) {
				ans++;
			}
			out.println(ans);
		}
	}

	static Throwable uncaught;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable uncaught) {
			Solution.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (Solution.uncaught != null) {
			throw Solution.uncaught;
		}
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

	public String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class _342C {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        double r;
        double h;
        final double a = 1.70710678119;
        String s[] = input.readLine().split(" ");
        r = Double.parseDouble(s[0]);
        h = Double.parseDouble(s[1]);
        double cond = 0.0;
        int count = 0;
        while (cond + r <= h + r / 2.0) {
            count += 2;
            cond += r;
        }
        if (h + r - cond >= a * r / 2.0) {
            count++;
        }
        System.out.println(count);
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Trung Pham
 */
public class C {

    public static int[][][] dp;
    public static String val;
    public static int m;

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        double r = in.nextInt();
        double h = in.nextInt();
        int a = (int) (1 + 2*Math.floor(h / r));
        int b = 0;
        if( h - (r / 2) >= 0){
            h -= (r/2);
            b = (int) (2 + 2*Math.floor(h / r));
        }
        out.println(Math.max(a , b));

        out.close();

    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists())
                System.setIn(new FileInputStream("input.txt"));
        } catch (SecurityException e) {
        }
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    private void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int r = nextInt();
        int h = nextInt();
        int p = h/r;
        p*=2;
        int c = h%r;
        p++;

        double as = (double)r/2;
        int ty = (int)(as+1-0.000001);

        if (c >= ty) p++;
        out.println(p);

        in.close();
        out.close();
    }

    void chk(boolean b) {
        if (b)
            return;
        System.out.println(new Error().getStackTrace()[1]);
        exit(999);
    }
    void deb(String fmt, Object... args) {
        System.out.printf(Locale.US, fmt + "%n", args);
    }
    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }
    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }
}


import java.util.*;

  public class demo
{

    public static void main(String[] args) throws IOException
    { BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer s=new StringTokenizer(inp.readLine());
      int n,k;
      n=Integer.parseInt(s.nextToken());
      k=Integer.parseInt(s.nextToken());
      String A=inp.readLine();
      int lets[]=new int[26],flag=0;
      int lets1[]=new int[26];
      for(int i=0;i<n;i++)
    	lets[A.charAt(i)-65]++;
      int count=k;
      for(int i=0;i<n;i++)
      {if(lets1[A.charAt(i)-65]==0)
    	  count--;

    	  lets1[A.charAt(i)-65]++;
      if(lets1[A.charAt(i)-65]==lets[A.charAt(i)-65])
    	  count++;
      if(count<0)
      {
    	  flag=1;
    	  break;
      }
      }
      if(flag==1)
    	  System.out.println("YES");
      else
    	  System.out.println("NO");

     }
    }


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Prince Raj
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int guest = in.readInt();
            int guard = in.readInt();

            String s = in.readToken();
            char[] door = s.toCharArray();

            int[] last = new int[26];
            int[] begin = new int[26];

            for (int i = 0; i < 26; i++) {
                last[i] = -1;
                begin[i] = -1;
            }

            for (int i = 0; i < guest; i++) {
                last[door[i] - 'A'] = i;
            }
            for (int i = guest - 1; i >= 0; i--) {
                begin[door[i] - 'A'] = i;
            }

            int maxOpenDoor = 0;
            for (int i = 0; i < guest; i++) {
                int openDoor = 0;
                for (int j = 0; j < 26; j++) {
                    if (i >= begin[j] && i <= last[j]) {
                        openDoor++;
                    }
                }
                maxOpenDoor = Math.max(openDoor, maxOpenDoor);
            }
            if (maxOpenDoor > guard) {
                out.print("YES");
            } else {
                out.print("NO");
            }

        }

    }

    static class InputReader {
        public InputReader;

        public int readInt();

        public String readToken();

    }
}


import sun.nio.ch.SctpAssocChange;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class CF_834B {
    private static Entrance[] entrances = new Entrance[26];

    static void add_guest(int entrance, int num_guest) {
        if (entrances[entrance] == null)
            entrances[entrance] = new Entrance(num_guest);
        else
            entrances[entrance].lastNumGuest = num_guest;
    }

    public static void main(String argv[]) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        String test = sc.next();

        int[] map = new int[27];

        for (int i = 0; i < test.length(); i++) {
            add_guest(test.charAt(i) - 65, i);
        }

        for (Entrance entrance : entrances) {
            if (entrance != null) {
                map[entrance.firstNumGuest]++;
                map[entrance.lastNumGuest+1]--;
            }
        }

        //System.out.println(Arrays.toString(map));

        int[] result = new int[27];
        int cnt=0;
        for (int i = 0; i < 26; i++) {
            cnt += map[i];
            result[i] = cnt;
        }

       // System.out.println(Arrays.toString(result));

        int max = 0;
        for (int i = 0; i < 27; i++)
            if (result[i] > max)
                max = result[i];

        System.out.println((max > k ? "YES":"NO"));
    }
}

class Entrance {
    int firstNumGuest,lastNumGuest;

    Entrance(int firstNum) {
        firstNumGuest = firstNum;
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String args[])
            throws java.io.IOException{
        Scanner in = new Scanner(System.in);

        int s[] = new int[27];
        int d[] = new int[27];
        int n = in.nextInt();
        int k=in.nextInt();
        int k1=k;

        String im = in.next();
        for(int i=0; i<n; i++)
        {
            int b = im.charAt(i)- (char)'A';
            s[b]++;
        }

        for(int i=0; i<n; i++)
        {
            int b = im.charAt(i)- (char)'A';
            if (d[b]==0) k1--;
            d[b]++;
            if(k1<0) {System.out.println("YES");  return;}
            if (d[b]==s[b]) k1++;
        }

        System.out.println("NO");

    }


// package Contest596;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

import Contest596.A.FastReader;

public class C {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();
		int n = scn.nextInt();
		int p = scn.nextInt();
//ArrayList<Integer>
		int ans = -1;
		for (int k = 1; k <= 32; k++) {
			long x = n - k * p;
			int y = Long.bitCount(x);
			if (y <= k && x >= k) {
				ans = k;
				break;
			}

		}
//		printSubsetsRec(arr, 0, n, new ArrayList<Integer>());
//		printAllSubsets(arr, arr.length, n);
//		int res = minCoins(arr, arr.length, n);
		System.out.println(ans);
	}

	static int minCoins(int coins[], int m, int V) {
		// table[i] will be storing
		// the minimum number of coins
		// required for i value. So
		// table[V] will have result
		int table[] = new int[V + 1];

		// Base case (If given value V is 0)
		table[0] = 0;

		// Initialize all table values as Infinite
		for (int i = 1; i <= V; i++)
			table[i] = Integer.MAX_VALUE;

		// Compute minimum coins required for all
		// values from 1 to V
		for (int i = 1; i <= V; i++) {
			// Go through all coins smaller than i
			for (int j = 0; j < m; j++)
				if (coins[j] <= i && coins[j] >= 0) {
					int sub_res = table[i - coins[j]];
					if (sub_res != Integer.MAX_VALUE && sub_res + 1 < table[i])
						table[i] = sub_res + 1;

				}

		}
		return table[V];

	}

	static int solveExp(int a, int x) {
//		a = a % mod;
		int res = 1;

		while (x > 0) {
			if ((x & 1) == 1)
				res = (res * a);
			a = (a * a);
			x >>= 1;
		}

		return res;
	}
}


import java.util.Scanner;
import java.util.TreeMap;

public class Codeforces {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n, p;
        n = sc.nextLong();
        p = sc.nextLong();
        long ans = Long.MAX_VALUE;
        for(int i = 1; i < 65; i++){
            long target = n - i*p;
            int bits = 0;
            if(target <= 0){
                break;
            }
            int maxx = target;
            while(target > 0){
                if(target % 2 == 1){
                    bits++;
                }
                target /= 2;
            }
            if( i >= bits && i <= maxx){
                ans = i;
                break;
            }
        }
        System.out.println((ans == Long.MAX_VALUE) ? -1 : ans);
    }

}


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner (System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        for (int res = 1; res < 31; res++) {
            long  cur = n - res * p;
            int numbit=Long.bitCount(cur);
            if(numbit<=res&&cur>0) {
                System.out.print(res);
                return;
            }
        }
        System.out.print(-1);
    }
}


// Why do we fall ? So we can learn to pick ourselves up.
import java.util.*;
public class solve {
    static int mod = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int p = sc.nextInt();
        ArrayList<Long> tt = new ArrayList<>();
        for(int i=0; i<40; i++){
            tt.add((long) (Math.pow(2,i)+p));
        }
        int[] table = new int[(int) (n+1)];
        table[0] = 0;
        for(int i=1; i<=n; i++){
            table[i] = Integer.MAX_VALUE;
        }
        for(int i=1; i<=n; i++){
            for(int j=0; j<tt.size(); j++){
                if(i >= tt.get(j)){
                    int sr = table[(int) (i-tt.get(j))];
                    if(sr != Integer.MAX_VALUE && sr+1<table[i]){
                        table[i] = sr+1;
                    }
                }
            }
        }
        if(table[(int)n] != Integer.MAX_VALUE){
            System.out.println(table[(int) n]);
        } else {
            System.out.println(-1);
        }
    }
}


import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main
{
	static final long mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=true;
	static Reader in=new Reader();
	public static void main(String[] args) throws IOException
	{
		int a=ni(),b=ni(),k=ni(),t=ni();
		long dp[][]=new long[2*t+1][4*k*t+1];
		dp[0][2*t*k]=1;
		for(int i=1; i<=2*t; i++)
		{
			for(int j=0; j<k; j++)
			{
				dp[i][0]=(dp[i][0]+dp[i-1][j])%mod;
				dp[i][j+k+1]=(dp[i][j+k+1]-dp[i-1][j])%mod;
			}
			for(int j=k; j<4*k*t-k; j++)
			{
				dp[i][j-k]=(dp[i][j-k]+dp[i-1][j])%mod;
				dp[i][j+k+1]=(dp[i][j+k+1]-dp[i-1][j])%mod;
			}
			for(int j=4*k*t-k; j<=4*k*t; j++)
				dp[i][j-k]=(dp[i][j-k]+dp[i-1][j])%mod;
			for(int j=1; j<=4*k*t; j++)
				dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
		}
		long an=0;
		for(int i=b-a+1+2*t*k; i<=4*k*t; i++)
		{
			an=(an+dp[2*t][i])%mod;
		}
		pr((an+mod)%mod);
		System.out.println(ans);
	}
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static int ni(){return in.nextInt();}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}


import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class A {
    static class Node implements Comparable<Node>{
        int x;
        long w;
        int id;

        public Node(int x,long w,int id){
           this.x=x;
           this.w=w;
           this.id=id;
        }
        public int compareTo(Node c){
            int i=Long.compare(this.w,c.w);
          return i;

        }
        @Override
        public boolean equals(Object o){
            if(o instanceof Node){
                Node c = (Node)o;
                return true;
            }
            return false;
        }
    }

    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static void solve() throws IOException {
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int a=sc.I(); int b=sc.I();  k=sc.I(); int n=sc.I();
        int MX=200001;
        dp1=new long[n+1][2*MX+1];
        dp2=new long[n+1][2*MX+1];

        dp1[0][a+MX]=1;
        dp2[0][b+MX]=1;
        int mx=Math.max(a,b)+k*n+MX;
        int mn=Math.min(a,b)-k*n+MX;

        for(int i=1;i<=n;i++) {
             for(int j=mn;j<=mx;j++){

                     dp1[i][j - k] += dp1[i - 1][j];
                     dp1[i][j + k + 1] -= dp1[i - 1][j];

                     dp2[i][j - k] += dp2[i - 1][j];
                     dp2[i][j + k + 1] -= dp2[i - 1][j];

             }
             for(int j=mn;j<=mx;j++){
                 dp1[i][j]=(dp1[i][j]+dp1[i][j-1])%M;
                 dp2[i][j]=(dp2[i][j]+dp2[i][j-1])%M;
             }

        }
        long ans=0;

        long sum2[]=new long[2*MX+1];

        for(int i=mn;i<=mx;i++){
            sum2[i]=(sum2[i-1]+dp2[n][i])%M;
        }
        for(int i=mn;i<=mx;i++){
            ans=(ans+(dp1[n][i]*sum2[i-1])%M)%M;
          //  pw.println(dp1[n][i]+" "+sum2[i-1]);

        }
        pw.println(ans);

        pw.close();

    }
    static long dp1[][];
    static long dp2[][];
    static int k;

    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}


import java.io.PrintWriter;
import java.util.*;

public class D {

	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static void exit() {
		sc.close();
		out.close();
	}

	long mod = 1000000007;
	int a, b, k, t;
	long c [][];
	int M;
	public D () {
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();
		t = sc.nextInt();
		M = Math.abs(2*t*k + a + b);
		c = new long [2*t+1][2*M];
		for (int i = 0; i < c.length; i++) {
			for (int j = 0; j < c[0].length; j++) {
				c[i][j] = -1;
			}
		}
		int m = 1 + b - a;
		out.println(comb(2*t, m));
	}

	long comb(int t, int m) {
		if (t == 0) {
			return 0 >= m ? 1 : 0;
		}
		if (c[t][M + m] != -1) return c[t][M+m];
		long sum = 0;
		for (int x = -k; x <= k; x++) {
			sum = (sum + comb(t-1, m-x)) % mod;
		}
		c[t][M+m] = sum;
		return sum;
	}

	public static void main(String[] args) {
		new D();
		exit();
	}
}


import java.io.PrintWriter;
import java.util.*;

public class D {

	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static void exit() {
		sc.close();
		out.close();
	}

	int mod = 1000000007;
	int a, b, k, t;
	int M;
	int c [][];
	int p [][];
	public D () {
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();
		t = sc.nextInt();
		M = Math.abs(2*t*k + a + b+k);
		c = new int [2*t+1][2*M+1];
		p = new int [2*t+1][2*M+1];
		for (int i = 0; i < c.length; i++) Arrays.fill(c[i], 0);
		for (int i = 0; i < p.length; i++) Arrays.fill(p[i], 0);
		// solve t = 0: c[0][m] = 1 if 0 <= m
		for (int m = 0; m <= M; m++) c[0][M+m] = 1;
		p[0][M+0] = c[0][M+0];
		for (int m = 1; m <= M; m++) p[0][M+m] = p [0][M+m-1] + c[0][M+m];

		// solve for t > 0
		for (int n = 1; n <= 2*t; n++) {
			for (int m = -n*k; m <= n*k; m++) {
				c[n][M+m] = (p[n-1][M+m+k] - p[n-1][M+m-k-1])%mod;
				if (c[n][M+m]<0) c[n][M+m] += mod;
			}
			for (int m = n*k+1; M+m <= 2*M; m++) c[n][M+m] = c[n][M+m-1];
			p[n][M-n*k] = c[n][M-n*k];
			for (int m = -n*k+1; m <= M; m++) p[n][M+m] = (p[n][M+m-1] + c[n][M+m])%mod;
		}
		/*
		for (int n = 0; n <= 2; n++) {
			for (int m = -n*k; m <= n*k; m++) {
				out.println("c[" + n + "][" + m + "]=" + c[n][M+m]);
			}
		}
		*/
		out.println(c[2*t][M+a-b-1]);
		//out.println(c(2*T, a-b-1));
	}

	int c(int n, int m) {
		if (n == 0) {
			return 0<=m ? 1 : 0;
		}
		if (m < -n*k) return 0;
		if (m > n*k) return c(n, n*k);
		if (c[n][M+m] != -1) return c[n][M+m];
		c[n][M+m] = p(n-1, m+k) - p(n-1, m-k-1);
		//out.println("c["+n+"]["+m+"]=" + c[n][M+m]);
		return c[n][M+m];
	}

	int p(int n, int m) {
		if (m < -n*k) return 0;
		if (p[n][M+m] != -1) return p[n][M+m];
		p[n][M+m] = p(n, m-1) + c(n, m);
		//out.println("p["+n+"]["+m+"]=" + p[n][M+m]);
		return p[n][M+m];
	}

	public static void main(String[] args) {
		new D();
		exit();
	}
}


import java.util.*;
public class Yes
{
    public static void main(String  ... args)
    {
        Scanner ss=new Scanner(System.in);
        int n=ss.nextInt();
        if(n%2)
        System.out.println("white\n1 2");
        else
        System.out.println("black");
    }
}


import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        if(n%2==0)
        {
            pn("white");
            pn("1 2");
        }
        else pn("black");
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}v


public class VasyaAndChess
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%2 != 0)
			System.out.println("black");
		else
		{
			System.out.println("white");
			System.out.println(1 + " " + 2);
		}
		sc.close();
	}
}


    import java.util.Scanner;

    public class Solution{

        public static void main(String args[]){
            Scanner scn = new Scanner(System.in);
            long n = scn.nextLong();
            StringBuilder sb = new StringBuilder();
            if((n%2 == 0){
                sb.append("white");
                sb.append("\n");
                sb.append("1 2");
                System.out.println(sb.toString());
                return;
            }
            sb.append("black");
            System.out.println(sb.toString());
        }
    }


import java.util.Scanner;

public class PieRules {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = in.nextInt();
        }
        int[] dp = new int[N];
        dp[N-1] = arr[N-1];
        int sum = arr[N-1];
        for (int i = N-2; i>= 0; i--) {
            dp[i] = Math.max(dp[N+1], arr[N-1] + sum - dp[N+1]);
            sum += arr[i];
        }
        System.out.println(dp[N-1] + " " + (sum - dp[N-1]));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class MemSql {

	static int[] arr;
	static int[] com;
	static int[][] dp;

	public static int solve(int i, int opp) {
		if (i == arr.length)
			return com[com.length - 1] - opp;
		if (dp[i][opp] != -1)
			return dp[i][opp];
		int sum = com[i] - opp;
		int Give = solve(i + 1, opp + arr[i]);
		int Take = com[com.length - 1] - (solve(i + 1, sum));
		return dp[i][opp] = Math.max(Give, Take);

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		arr = new int[N + 1];
		com = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			arr[i] = sc.nextInt();
			com[i] = com[i - 1] + arr[i];
		}
		dp = new int[N + 1][N * 100000 + 1];
		for (int i = 0; i <= N; i++)
			Arrays.fill(dp[i], -1);
		System.out.println(com[N] - solve(1, 0) + " " + solve(1, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public boolean nextEmpty() throws IOException {
			String s = nextLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int n;
        int a;
        int dp;

        int dfs(int i, int player) {

            if (i == n)
                return 0;

            if (dp[i][player] != -1)
                return dp[i][player];

//        int nxt = (player == 1 ? 2 : 1);

            int x = a[i] + dfs(i + 1, 2);
            int y = dfs(i + 1, 1);

            if (player == 1)
                dp[i][player] = Integer.max(x, y);
            else
                dp[i][player] = Math.min(x, y);

            return dp[i][player];
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            n = in.nextInt();
            a = new int[n];

            int sum = 0;
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                sum += a[i];
            }

            dp = new int[n][3];
            for (int i = 0; i < n; ++i)
                Arrays.fill(dp[i], -1);

            int bob = dfs(0, 1);
            int alice = sum - bob;

            out.println(alice + " " + bob);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public String test_string;

        public InputReader(InputStream test_stringeam) {
            reader = new BufferedReader(new InputStreamReader(test_stringeam), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = null;
                    if (test_string != null) {
                        line = test_string;
                        test_string = null;
                    } else
                        line = reader.readLine();

                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.*;

public class Pie {
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int n = in.nextInt();
			int a[] = new int [n+1];
			int sum[] = new int[n+1];

			for(int i = 0; i<n; i++){
				a[i] = in.nextInt();
			}

			sum[n] = 0;
			int dp[] = new int [n+1];
			for(int i = n-1; i>=0; i--){

				sum[i] = sum[i+1]+a[i];
				dp[i] = Math.max(dp[i+1], sum[i+1]-dp[i+1]+a[i]);
			}
			System.out.println((sum[0]-dp[0])+" "+dp[0]);
		}
}


java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String lo = String.valueOf(in.nextInt());
            String hi = String.valueOf(in.nextInt());

            boolean loImportant = true, hiImportant = true;
            if (lo.length() < hi.length()) {
                loImportant = false;
            }

            boolean prioUp = true;
            StringBuilder sb = new StringBuilder();
            if (!loImportant) {
                if (hi.charAt(0) >= '5') {
                    hiImportant = false;
                    sb.append('4');
                } else {
                    sb.append(hi.charAt(0));
                }
            } else if (lo.charAt(0) == hi.charAt(0)) {
                sb.append(lo.charAt(0));
                prioUp = lo.charAt(0) <= '4';
            } else if (hi.charAt(0) > '5') {
                hiImportant = false;
                if (lo.charAt(0) < '5') {
                    loImportant = false;
                }

                sb.append('5');
                prioUp = false;
            } else if (lo.charAt(0) < '4') {
                loImportant = false;
                if (hi.charAt(0) > '5') {
                    hiImportant = false;
                }

                sb.append('4');
            } else if (hi.length() == 1) {
                sb.append('4');
            } else if (lo.charAt(1) > '0') {
                loImportant = false;
                sb.append('5');
                prioUp = false;
            } else {
                hiImportant = false;
                sb.append('4');
            }

            for (int i = 1; i < hi.length(); ++i) {
                char c;
                if (prioUp) {
                    c = '9';
                    for (; c >= '0'; --c) {
                        if (!hiImportant || c <= hi.charAt(i)) {
                            break;
                        }
                    }
                } else {
                    c = '0';
                    for (; c <= '9'; ++c) {
                        if (!loImportant || c >= lo.charAt(i)) {
                            break;
                        }
                    }
                }

                sb.append(c);
                hiImportant &= c == hi.charAt(i);
                loImportant &= i < lo.length() && c == lo.charAt(i);
            }

            String s = sb.toString();

            StringBuilder s2 = new StringBuilder();
            for (char c : s.toCharArray()) {
                s2.append('9' - c);
            }

            long ans = Long.parseLong(s) * Long.parseLong(s2.toString());

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.Scanner;

public class Reflexe2 {

    public static int reflexe(long cislo) {
        String cisloString = Long.toString(cislo);
        int vysledek = 0;
        for (int i = 0; i < cisloString.length(); i++) {
            vysledek = vysledek + 9 - (cisloString.charAt(i) - 48);
            if (i != cisloString.length() - 1) {
                vysledek = vysledek * 10;
            }
        }
        return (vysledek);
    }

    public static void main(String[] args) {
        Scanner mujScanner = new Scanner(System.in);

        long minCislo = mujScanner.nextLong();
        long maxCislo = mujScanner.nextLong();
        long desetiny = 1;

        String prevedeni1 = Long.toString(minCislo);
        String prevedeni2 = Long.toString(maxCislo);

        if (prevedeni1.length() < prevedeni2.length()) {
            for (int i = prevedeni1.length(); i < prevedeni2.length(); i++) {
                minCislo = minCislo * 10;
            }
        }

        if (prevedeni1.charAt(0) - 48 <= 5 && prevedeni2.charAt(0) - 48 >= 5) {
            desetiny = 5;
            for (int i = 1; i < prevedeni2.length(); i++) {
                desetiny = desetiny * 10;
            }
        } else if (prevedeni1.charAt(0) - 48 >= 5 && prevedeni2.charAt(0) - 48 >= 5) {
            desetiny = minCislo;
            for (int i = prevedeni1.length(); i < prevedeni2.length(); i++) {
                desetiny = desetiny * 10;
            }
        } else if (prevedeni1.charAt(0) - 48 <= 5 && prevedeni2.charAt(0) - 48 <= 5) {
            desetiny = maxCislo;
            for (int i = prevedeni1.length(); i < prevedeni2.length(); i++) {
                desetiny = desetiny * 10;
            }
        }
        System.out.println(reflexe(desetiny) * desetiny);

//
//        if (desetiny != 1) {
//            minCislo = desetiny;
//        }
//
//
//        long vysledek = 0L;
//        long mezipocet = 0L;
//
//        vysledek = reflexe(minCislo) * minCislo;
//        for (long i = minCislo; i <= maxCislo; i++) {
//            mezipocet = reflexe(i) * i;
//            if (mezipocet > vysledek) {
//                vysledek = reflexe(i) * i;
//            }
//        }
//        System.out.println(vysledek);
    }


package code;

import FastIO.InputReader;
import java.io.PrintWriter;

public class Task {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String lo = String.valueOf(in.nextInt());
        String hi = String.valueOf(in.nextInt());

        boolean loImportant = true, hiImportant = true;
        if (lo.length() < hi.length()) {
            loImportant = false;
        }

        boolean prioUp = true;
        StringBuilder sb = new StringBuilder();
        if (!loImportant) {
            if (hi.charAt(0) >= '5') {
                hiImportant = false;
                sb.append('4');
            } else {
                sb.append(hi.charAt(0));
            }
        } else if (lo.charAt(0) == hi.charAt(0)) {
            sb.append(lo.charAt(0));
            prioUp = lo.charAt(0) <= '4';
        } else if (hi.charAt(0) > '5') {
            hiImportant = false;
            if (lo.charAt(0) < '5') {
                loImportant = false;
            }

            sb.append('5');
            prioUp = false;
        } else if (lo.charAt(0) < '4') {
            loImportant = false;
            if (hi.charAt(0) > '5') {
                hiImportant = false;
            }

            sb.append('4');
        } else if (hi.length() == 1) {
            sb.append('4');
        } else if (lo.charAt(1) > '0') {
            loImportant = false;
            sb.append('5');
            prioUp = false;
        } else {
            hiImportant = false;
            sb.append('4');
        }

        for (int i = 1; i < hi.length(); ++i) {
            char c;
            if (prioUp) {
                c = '9';
                for (; c >= '0'; --c) {
                    if (!hiImportant || c <= hi.charAt(i)) {
                        break;
                    }
                }
            } else {
                c = '0';
                for (; c <= '9'; ++c) {
                    if (!loImportant || c >= lo.charAt(i)) {
                        break;
                    }
                }
            }

            sb.append(c);
            hiImportant &= c == hi.charAt(i);
            loImportant &= i < lo.length() && c == lo.charAt(i);
        }

        String s = sb.toString();

        StringBuilder s2 = new StringBuilder();
        for (char c : s.toCharArray()) {
            s2.append('9' - c);
        }

        long ans = Long.parseLong(s) * Long.parseLong(s2.toString());

        out.println(ans);
    }
}


/*import java.util.Scanner;

public class A86
{
    public static void main(String[] args)
    {
        Scanner in=new Scanner (System.in);

        long l=in.nextInt();
        long r=in.nextInt();
        long best=Math.max(func (l),func(r));
        for(long i=5; i<r; i*=10)
        {
            if(i>=l)
            {
                best=Math.max(best,func(i));
            }
        }
        System.out.print(best);

    }
    public static long func(long x)
    {
        char rr[]=String.valueOf(x).toCharArray();
        for(int i=0; i<rr.length; i++)
        {
            rr[i]=(char) ('9'-rr[i]);

        }
        long best=Long.parseLong(new String (rr));
        return x*best;

    }

}**/
    import java.util.*;

    public class a {
      public static void main(String[] args) {
                   Scanner in = new Scanner(System.in);
               int a = in.nextInt();
              int b = in.nextInt();

          long best = Math.max(w(a),w(b));

               for(long i=5; i <= b; i*=10) {
                  if(i >= a)
                           best = Math.max(best,w(i));
             }
             System.out.println(best);
    }
    public static long w(long x) {
     char[] v = String.valueOf(x).toCharArray();
            for(int i=0; i<v.length; i++)
               v[i] = (char)('9'+'0'-v[i]);
        long refl = Long.parseLong(new String(v));
             return x*refl;
  }
 }


import java.util.*;
import java.io.*;
public class Main {
    static int n, m;
    static Integer[] arr;
	public static void main (String[] args) throws IOException {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String[] line = br.readLine().split(" ");
	    n = p(line[0]);
	    m = p(line[1]);
	    arr = new Integer[n];
	    line = br.readLine().split(" ");
	    for(int i = 0; i < n; ++i) arr[i] = p(line[i]);
	    Arrays.sort(arr);

	    if(!go(n)){
	        System.out.println(-1);
	        return;
	    }
	    int l = 0, h = n + 1;
	    while(l != h){
	        int g = (l + h) / 2;

	        if(g > n){
	            System.out.println(-1);
	            return;
	        }

	        if(go(g)) h = g;
	        else l = g + 1;
	    }

	    System.out.println(l);
	}
	static boolean go(int in){
	    int tot = 0;
	    int idx = n - 1;
	    floop : for(int j = 0; ; ++j){
	        for(int i = 0; i < in; ++i){
	            tot += Math.max(arr[idx] - j, 0);
	            --idx;
	            if(idx == -1) break floop;
	        }
	    }
	   // System.out.println(in + " " + tot);
	    return tot >= m;
	}
	static int p(String in){
	    return Integer.parseInt(in);
	}
}


import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution
{
    static class InputReader
    {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream st)
        {
          this.stream = st;
        }

        public int read()
        {
          if (snumChars == -1)
            throw new InputMismatchException();
          if (curChar >= snumChars)
          {
            curChar = 0;
            try
            {
              snumChars = stream.read(buf);
            } catch (IOException e)
            {
              throw new InputMismatchException();
            }
            if (snumChars <= 0)
              return -1;
          }
          return buf[curChar++];
        }

        public int nextInt()
        {
          int c = read();
          while (isSpaceChar(c))
          {
            c = read();
          }
          int sgn = 1;
          if (c == '-')
          {
            sgn = -1;
            c = read();
          }
          int res = 0;
          do
          {
            res *= 10;
            res += c - '0';
            c = read();
          } while (!isSpaceChar(c));
          return res * sgn;
        }

        public long nextLong()
        {
          int c = read();
          while (isSpaceChar(c))
          {
            c = read();
          }
          int sgn = 1;
          if (c == '-')
          {
            sgn = -1;
            c = read();
          }
          long res = 0;
          do
          {
            res *= 10;
            res += c - '0';
            c = read();
          } while (!isSpaceChar(c));
          return res * sgn;
        }

        public int[] nextIntArray(int n)
        {
          int a[] = new int[n];
          for (int i = 0; i < n; i++)
          {
            a[i] = nextInt();
          }
          return a;
        }

        public String readString()
        {
          int c = read();
          while (isSpaceChar(c))
          {
            c = read();
          }
          StringBuilder res = new StringBuilder();
          do
          {
            res.appendCodePoint(c);
            c = read();
          } while (!isSpaceChar(c));
          return res.toString();
        }

        public String nextLine()
        {
          int c = read();
          while (isSpaceChar(c))
            c = read();
          StringBuilder res = new StringBuilder();
          do
          {
            res.appendCodePoint(c);
            c = read();
          } while (!isEndOfLine(c));
          return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c)
        {
          return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static long power(long a,long b,long mod)
    {
        if(b==0)
            return 1;
        else if(b==1)
            return a;
        else
        {
            if(b%2==1)
            {
                long p=power(a,b/2,mod);
                return((p*p*a)%mod);
            }
            else
            {
                long p1=power(a,b/2,mod);
                return((p1*p1)%mod);
            }
        }
    }
    public static boolean possible(long x,ArrayList<Long> al,long[] suf,long m)
    {
        boolean ret=false;
        int n=al.size();
        long sum=0;
        long count=0;
        long i=n-x;
        long prev=i;
        for(i=n-x;i>=0;i-=(x))
        {
            sum+=(long)Math.max(0,suf[(int)i]-suf[(int)(i+x)]-(count*x));
            count++;
            if(sum>=m)
            {
                return true;
            }
            prev=i;
        }
        if(i<0)
        {
            sum+=(long)Math.max(0,suf[0]-suf[(int)prev]-(count*(prev)));
            if(sum>=m)
                return true;
        }
        if(sum>=m)
        {
            return true;
        }
        return false;
    }
    public static long mod=1000000007;
    public static void main(String[] args) throws IOException
    {
        InputReader in=new InputReader(System.in);
        PrintWriter w=new PrintWriter(System.out);
        int n=in.nextInt();
        long m=in.nextLong();
        ArrayList<Long> al=new ArrayList<Long>();
        for(int i=0;i<n;i++)
        {
            al.add(in.nextLong());
        }
        Collections.sort(al);
        long[] suf=new long[n+1];
        suf[n]=0;
        suf[n-1]=al.get(n-1);
        for(int i=n-2;i>=0;i--)
        {
            suf[i]=suf[i+1]+al.get(i);
        }
        long lo=1,hi=n,mid=lo+((hi-lo)/2);
        long ans=m;
        while(lo<=hi)
        {
            if(possible(mid,al,suf,m))
            {
                //w.println("acc "+mid);
                hi=mid-1;
                ans=mid;
            }
            else
            {
                //w.println("rej "+mid);
                lo=mid+1;
            }
            mid=lo+((hi-lo)/2);
        }
        //possible(1,al,suf,m);
        if(suf[0]>=m)
            w.println(ans);
        else
            w.println("-1");
        w.close();
    }
}