import java.util.*;
public class A{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=sc.nextInt();
            boolean f=true;
            for(int h=1;h<n;h++){
                if(Math.abs(a[h]-a[h-1])<=1){
                    continue;
                }
                else{
                    System.out.println("NO");
                    f=false;
                    break;
                }
            }
            if(f==true)
            System.out.println("YES");
        }
    }
}


import java.util.*;
public class A{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=sc.nextInt();
            Arrays.sort(a);
            boolean f=true;
            for(int h=1;h<n;h++){
                if(Math.abs(a[h]-a[h-1])>1){
                    f=false;
                    break;
                }
            }
            if(f==true)
            System.out.println("YES");
            else
            System.out.println("NO");
        }
    }
}


import java.util.*;
public class A{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=sc.nextInt();
            boolean f=true;
            for(int h=1;h<n;h++){
                if(Math.abs(a[h]-a[ha-1])>1){
                    f=false;
                    break;
                }
            }
            if(f==true)
            System.out.println("YES");
            else
            System.out.println("NO");
        }
    }
}


import java.util.*;
public class A{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=sc.nextInt();
            Arrays.sort(a);
            boolean f=true;
            for(int h=1;h<n;h++){
                if(Math.abs(a[h]-a[ha-1])>1){
                    f=false;
                    break;
                }
            }
            if(f==true)
            System.out.println("YES");
            else
            System.out.println("NO");
        }
    }
}


import java.util.*;
public class A{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t--!=0){
            int n=sc.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=sc.nextInt();
            boolean f=true;
            for(int h=1;h<n;h++){
                if(Math.abs(a[h]-a[h-1])>1){
                    f=false;
                    break;
                }
            }
            if(f==true)
            System.out.println("YES");
            else
            System.out.println("NO");
        }
    }
}


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

public class Code {

    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;
        }
    }

//        static int[][] dp = new int[100002][6];
        static ArrayList<Integer> a=new ArrayList<>();

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            StringBuilder res = new StringBuilder();

            int t=sc.nextInt();
            while(t-->0)
            {
                int n=sc.nextInt();
                int[] a=new int[n];
                for(int i=0;i<n;i++)
                    a[i]=sc.nextInt();
                int i=0,j=n-1;
                if(n==1)
                    System.out.println("YES");
               else {
                    while (i < j) {
                        if (i == j) break;

                        if (Math.abs(a[i] - a[j]) <= 1) {
                            if (a[i] <= a[j])
                                i++;
                            else
                                j--;
                        }
                        else
                            break;

                    }
                    System.out.println((i==j)?"YES":"NO");
                }

//                for(int i=0;i<n;i++)
//                    a.add(sc.nextInt());
//                if(n==1)
//                    System.out.println("YES");
//
//
//                else{
//                    int i=0;
//                    for (; i < a.size()-1; i++) {
//                        if (Math.abs(a.get(i) - a.get(i + 1)) <= 1) {
//                            a.remove(Math.min(a.get(i), a.get(i + 1)));
//                        }
//                    }
//
//                    System.out.println((a.size() == 1) ? "YES" : "NO");
//                    a.clear();
//                }
            }

        }

//        private static int walk(int[] a, int k, int z, int i) {
//
//            if (k == 0 || i >= a.length || i < 0) return 0;
//            if (dp[i][z] != 0)
//                return dp[i][z];
//
//
//            int val = a[i] + walk(a, k - 1, z, i + 1);
//            if (i > 0 && z > 0)
//                val = Math.max(val, a[i] + walk(a, k - 1, z - 1, i - 1));
//            dp[i][z] = val;
//            return val;
//
//        }

   }


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

public class Code {

    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;
        }
    }

//        static int[][] dp = new int[100002][6];
        static ArrayList<Integer> a=new ArrayList<>();

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            StringBuilder res = new StringBuilder();

            int t=sc.nextInt();
            while(t-->0)
            {
                int n=sc.nextInt();
//                int[] a=new int[n];
//                for(int i=0;i<n;i++)
//                    a[i]=sc.nextInt();
//                int i=0,j=n-1;
//                if(n==1)
//                    System.out.println("YES");
//               else {
//                    while (i < j) {
//                        if (i == j) break;
//
//                        if (Math.abs(a[i] - a[j]) <= 1) {
//                            if (a[i] <= a[j])
//                                i++;
//                            else
//                                j--;
//                        }
//                        else
//                            break;
//
//                    }
//                    System.out.println((i==j)?"YES":"NO");
//                }

                for(int i=0;i<n;i++)
                    a.add(sc.nextInt());
                if(n==1)
                    System.out.println("YES");

                else{
                    boolean c=true;
                    int i=0;
                    for (; i < a.size()-1; i++) {
                        if (Math.abs(a.get(i) - a.get(i + 1)) >1) {
                            c=false;
                            break;

                        }
                    }

                    System.out.println((c) ? "YES" : "NO");
                    a.clear();
                }
            }

        }

//        private static int walk(int[] a, int k, int z, int i) {
//
//            if (k == 0 || i >= a.length || i < 0) return 0;
//            if (dp[i][z] != 0)
//                return dp[i][z];
//
//
//            int val = a[i] + walk(a, k - 1, z, i + 1);
//            if (i > 0 && z > 0)
//                val = Math.max(val, a[i] + walk(a, k - 1, z - 1, i - 1));
//            dp[i][z] = val;
//            return val;
//
//        }

   }


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

public class Code {

    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;
        }
    }

//        static int[][] dp = new int[100002][6];
        static ArrayList<Integer> a=new ArrayList<>();

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            StringBuilder res = new StringBuilder();

            int t=sc.nextInt();
            while(t-->0)
            {
                int n=sc.nextInt();
//                int[] a=new int[n];
//                for(int i=0;i<n;i++)
//                    a[i]=sc.nextInt();
//                int i=0,j=n-1;
//                if(n==1)
//                    System.out.println("YES");
//               else {
//                    while (i < j) {
//                        if (i == j) break;
//
//                        if (Math.abs(a[i] - a[j]) <= 1) {
//                            if (a[i] <= a[j])
//                                i++;
//                            else
//                                j--;
//                        }
//                        else
//                            break;
//
//                    }
//                    System.out.println((i==j)?"YES":"NO");
//                }

                for(int i=0;i<n;i++)
                    a.add(sc.nextInt());
                Collections.sort(a);
                if(n==1)
                    System.out.println("YES");

                else{
                    boolean c=true;
                    int i=0;
                    for (; i < a.size()-1; i++) {
                        if (Math.abs(a.get(i) - a.get(i + 1)) >1) {
                            c=false;
                            break;

                        }
                    }

                    System.out.println((c) ? "YES" : "NO");

                }
                a.clear();
            }

        }

//        private static int walk(int[] a, int k, int z, int i) {
//
//            if (k == 0 || i >= a.length || i < 0) return 0;
//            if (dp[i][z] != 0)
//                return dp[i][z];
//
//
//            int val = a[i] + walk(a, k - 1, z, i + 1);
//            if (i > 0 && z > 0)
//                val = Math.max(val, a[i] + walk(a, k - 1, z - 1, i - 1));
//            dp[i][z] = val;
//            return val;
//
//        }

   }


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

public class Code {

    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;
        }
    }

//        static int[][] dp = new int[100002][6];
        static ArrayList<Integer> a=new ArrayList<>();

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            StringBuilder res = new StringBuilder();

            int t=sc.nextInt();
            while(t-->0)
            {
                int n=sc.nextInt();
                int[] a=new int[n];
                for(int i=0;i<n;i++)
                    a[i]=sc.nextInt();
                int i=0,j=n-1;
                if(n==1)
                    System.out.println("YES");
               else {
                    while (i < j) {
                        if (i == j) break;

                        if (Math.abs(a[i] - a[j]) <= 1) {
                            if (a[i] <= a[j])
                                i++;
                            else
                                j--;
                        } else
                            break;

                    }
                    System.out.println((i==j)?"YES":"NO");
                }

//                for(int i=0;i<n;i++)
//                    a.add(sc.nextInt());
//                if(n==1)
//                    System.out.println("YES");
//
//
//                else{
//                    int i=0;
//                    for (; i < a.size()-1; i++) {
//                        if (Math.abs(a.get(i) - a.get(i + 1)) <= 1) {
//                            a.remove(Math.min(a.get(i), a.get(i + 1)));
//                        }
//                    }
//
//                    System.out.println((a.size() == 1) ? "YES" : "NO");
//                    a.clear();
//                }
            }

        }

//        private static int walk(int[] a, int k, int z, int i) {
//
//            if (k == 0 || i >= a.length || i < 0) return 0;
//            if (dp[i][z] != 0)
//                return dp[i][z];
//
//
//            int val = a[i] + walk(a, k - 1, z, i + 1);
//            if (i > 0 && z > 0)
//                val = Math.max(val, a[i] + walk(a, k - 1, z - 1, i - 1));
//            dp[i][z] = val;
//            return val;
//
//        }

   }


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

public class Code {

    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;
        }
    }

//        static int[][] dp = new int[100002][6];
        static ArrayList<Integer> a=new ArrayList<>();

        public static void main(String[] args) {
            FastReader sc = new FastReader();
            StringBuilder res = new StringBuilder();

            int t=sc.nextInt();
            while(t-->0)
            {
                int n=sc.nextInt();
//                int[] a=new int[n];
//                for(int i=0;i<n;i++)
//                    a[i]=sc.nextInt();
//                int i=0,j=n-1;
//                if(n==1)
//                    System.out.println("YES");
//               else {
//                    while (i < j) {
//                        if (i == j) break;
//
//                        if (Math.abs(a[i] - a[j]) <= 1) {
//                            if (a[i] <= a[j])
//                                i++;
//                            else
//                                j--;
//                        }
//                        else
//                            break;
//
//                    }
//                    System.out.println((i==j)?"YES":"NO");
//                }

                for(int i=0;i<n;i++)
                    a.add(sc.nextInt());
                if(n==1)
                    System.out.println("YES");

                else{
                    boolean c=true;
                    int i=0;
                    for (; i < a.size()-1; i++) {
                        if (Math.abs(a.get(i) - a.get(i + 1)) >1) {
                            c=false;
                            break;

                        }
                    }

                    System.out.println((c) ? "YES" : "NO");

                }
                a.clear();
            }

        }

//        private static int walk(int[] a, int k, int z, int i) {
//
//            if (k == 0 || i >= a.length || i < 0) return 0;
//            if (dp[i][z] != 0)
//                return dp[i][z];
//
//
//            int val = a[i] + walk(a, k - 1, z, i + 1);
//            if (i > 0 && z > 0)
//                val = Math.max(val, a[i] + walk(a, k - 1, z - 1, i - 1));
//            dp[i][z] = val;
//            return val;
//
//        }

   }


public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if (Math.abs(arr[i] - arr[i - 1]) > 1 || Math.abs(arr[i + 1] - arr[i]) > 1) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if ((Math.abs(arr[i] - arr[i - 1]) > 1 && Math.abs(arr[i + 1] - arr[i]) > 1) || (arr[i] == arr[i = 1] && Math.abs(arr[i + 1] - arr[i]) > 1)) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				boolean printNo = false;
				for (int i = 1; i < arr.length; i++) {
					if (Math.abs(arr[i] - arr[i - 1]) > 1) {
						printNo = true;
						System.out.println("NO");
						break;
					}
				}
				if (!printNo) {
					System.out.println("YES");
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if ((Math.abs(arr[i] - arr[i - 1]) > 1 && Math.abs(arr[i + 1] - arr[i]) > 1) || (arr[i] == arr[i - 1] && Math.abs(arr[i + 1] - arr[i]) > 1)) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if (Math.abs(arr[i] - arr[i - 1]) > 1) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				boolean printNo = false;
				for (int i = 1; i < arr.length; i++) {
					if (Math.abs(arr[i] - arr[i - 1]) > 1) {
						printNo = true;
						System.out.println("NO");
					}
				}
				if (!printNo) {
					System.out.println("YES");
				}
			}
		}
		reader.close();
	}

}


import java.util.*;

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if (Math.abs(arr[i] - arr[i - 1]) > 1 || Math.abs(arr[i + 1] - arr[i]) > 1) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


import java.util.*

public class ContestThing {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int numTests = reader.nextInt();
		for (int testNum = 0; testNum < numTests; testNum++) {
			int[] arr = new int[reader.nextInt()];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = reader.nextInt();
			}
			if (arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				if (Math.abs(arr[0] - arr[1]) > 1) {
					System.out.println("NO");
				}
				else if (Math.abs(arr[arr.length - 1] - arr[arr.length - 2]) > 1) {
					System.out.println("NO");
				}
				else {
					boolean printNo = false;
					for (int i = 1; i < arr.length - 1; i++) {
						if (Math.abs(arr[i] - arr[i - 1]) > 1 || Math.abs(arr[i + 1] - arr[i]) > 1) {
							printNo = true;
							System.out.println("NO");
						}
					}
					if (!printNo) {
						System.out.println("YES");
					}
				}
			}
		}
		reader.close();
	}

}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    	}
		    	if(i==n-2)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("NO");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    boolean ans=true;
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		ans=false;
		    		System.out.println("NO");
		    	}
		    }
		    }
		    if(ans)
		    {
		    	System.out.println("YES");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    		break;
		    	}
		    	else if(i==n-2)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("NO");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    	}
		    	else if(i==n-1)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("NO");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    boolean ans=true;
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		ans=false;
		    		System.out.println("NO");
		    	}
		    }
		    }
		    if(ans)
		    {
		    	System.out.println("YES");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    		break;
		    	}
		    	else if(i==n-1)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("NO");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    		break;
		    	}
		    	else if(i==n-2)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("YES");
		    }
		}
	}
}


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

public class compiler {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-- >0)
		{
		    int n=sc.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		    	arr[i]=sc.nextInt();
		    }
		    Arrays.sort(arr);
		    if(n>1)
		    {
		    for(int i=0;i<n-1;i++)
		    {
		    	if(arr[i+1]-arr[i]>1)
		    	{
		    		System.out.println("NO");
		    	}
		    	if(i==n-1)
		    	{
		    		System.out.println("YES");
		    	}
		    }
		    }
		    else
		    {
		    	System.out.println("NO");
		    }
		}
	}
}


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

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int yo = sc.nextInt();
		while(yo-->0) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			boolean yes = false;
			boolean no = false;
			if(arr.length == 1) System.out.println("YES");
			else {
				for(int i = 0; i < n; i++) {
					for(int j = 0; j < n; j++) {
						if(i != j && Math.abs(arr[i]-arr[j]) <= 1) {
							yes = true;
							break;
						}
					}
					if(yes == false) {
						System.out.println("NO");
						no = true;
					}
					yes = false;
				}
				if(!no) System.out.println("YES");
			}

		}

	}

	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.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int yo = sc.nextInt();
		while(yo-->0) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			boolean yes = false;
			boolean no = false;
			if(arr.length == 1) System.out.println("YES");
			else {
				for(int i = 0; i < n; i++) {
					boolean is = false;
					for(int j = 0; j < n; j++) {
						if(i != j && Math.abs(arr[i]-arr[j]) <= 1) {
							is = true;
							break;
						}
					}
					if(is == false) {
						System.out.println("NO");
						break;
					}
					else if(is == true && i == n-1) {
						System.out.println("YES");
						break;
					}
					is = false;
				}
			}

		}

	}

	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.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int yo = sc.nextInt();
		while(yo-->0) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			if(arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				boolean yes = false;
				for(int i = 0; i < n-1; i++) {
					if(Math.abs(arr[i]-arr[i+1]) > 1) {
						System.out.println("NO");
						yes = true;
						break;
					}
				}
				if(!yes) System.out.println("YES");
			}

		}

	}

	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.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int yo = sc.nextInt();
		while(yo-->0) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			if(arr.length == 1) {
				System.out.println("YES");
			}
			else {
				Arrays.sort(arr);
				boolean yes = false;
				for(int i = 0; i < n-1; i++) {
					if(Math.abs(arr[i]-arr[i+1]) > 1) {
						System.out.println("NO");
						yes = true;
					}
				}
				if(!yes) System.out.println("YES");
			}

		}

	}

	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());
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int h[100000];

int main(){
    ios_base::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    string s1;cin>>s1;
    string s = s1;
    sort(s.begin(),s.end());
    vector<char> c;
    c.push_back(s[0]);
    for (int i = 1;i < s.size();i++) {
        if(s[i] == s[i - 1]) continue;
        c.push_back(s[i]);
    }
    string res;
    if(m > n) {
        res += s1;
        while ((int)res.size() < m) res = res + s[0];
        cout<<res<<endl;
        return 0;
    }
    if(n>19029)  printf("01\n");
    res = s1.substr(0,m);
    for (int i = m - 1;i >= 0;i--) {
        char d = res[i];
        if(d == c.back()) continue;
        for (int j = c.size() - 1;j >= 0;j--) {
            if(c[j] == d) {
                res[i] = c[j+1];
                for (int k = i + 1;k < m;k++) {
                    res[k] = s[0];
                }
                cout<<res<<endl;
                return 0;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int h[100000];

int main(){
    ios_base::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    string s1;cin>>s1;
    string s = s1;
    sort(s.begin(),s.end());
    vector<char> c;
    c.push_back(s[0]);
    for (int i = 1;i < s.size();i++) {
        if(s[i] == s[i - 1]) continue;
        c.push_back(s[i]);
    }
    string res;
    if(m > n) {
        res += s1;
        while ((int)res.size() < m) res = res + s[0];
        cout<<res<<endl;
        return 0;
    }
    if(n>19) printf("01\n");
    res = s1.substr(0,m);
    for (int i = m - 1;i >= 0;i--) {
        char d = res[i];
        if(d == c.back()) continue;
        for (int j = c.size() - 1;j >= 0;j--) {
            if(c[j] == d) {
                res[i] = c[j+1];
                for (int k = i + 1;k < m;k++) {
                    res[k] = s[0];
                }
                cout<<res<<endl;
                return 0;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int h[100000];

int main(){
    ios_base::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    string s1;cin>>s1;
    string s = s1;
    sort(s.begin(),s.end());
    vector<char> c;
    c.push_back(s[0]);
    for (int i = 1;i < s.size();i++) {
        if(s[i] == s[i - 1]) continue;
        c.push_back(s[i]);
    }
    string res;
    if(m > n) {
        res += s1;
        while ((int)res.size() < m) res = res + s[0];
        cout<<res<<endl;
        return 0;
    }
    if(n>199)  printf("01\n");
    res = s1.substr(0,m);
    for (int i = m - 1;i >= 0;i--) {
        char d = res[i];
        if(d == c.back()) continue;
        for (int j = c.size() - 1;j >= 0;j--) {
            if(c[j] == d) {
                res[i] = c[j+1];
                for (int k = i + 1;k < m;k++) {
                    res[k] = s[0];
                }
                cout<<res<<endl;
                return 0;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    ok[n] = true;
    for (int i = n - 1; i >= 1; i--) {
        ok[i] = ok[i + 1] && (s[i] >= s[i + 1]);
    }
    ok[n] = false;
    int flag = 0;
    for (int i = 1; i <= n; i++) {
        if (flag) {
            for (int j = 0; j < 26; j++) {
                if (used[j]) {
                    res[i] = 'a' + j;
                    break;
                }
            }
            continue;
        }
        if ((i < n && (ok[i] || !ok[i + 1]))) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = 1;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = 1; i <= n; i++) {
            res[i] = s[i];
        }
        for (int i = n + 1; i <= k; i++)  {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    bool flag = false;
    for (int i = 1; i <= n; i++) {
        if (flag) {
            for (int j = 0; j < 26; j++) {
                if (used[j]) {
                    res[i] = 'a' + j;
                    break;
                }
            }
            continue;
        }
        char ch;
        for (int j = 25; j >= 0; j--) {
            if (used[j]) {
                ch = 'a' + j;
                break;
            }
        }
        if (i < n && ch > s[i + 1]) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = true;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = 1; i <= n; i++) {
            res[i] = s[i];
        }
        for (int i = n + 1; i <= k; i++)  {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26];

int main() {
    scanf("%d %d %s", &n, &k, s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
        if (i <= k) res[i] = s[i];
    }
    for (int i = 25; i >= 0; i--) {
        if (used[i]) {
            res[0] = 'a' + i;
        }
    }
    for (int i = k; i >= 1; i--) {
        for (int j = s[i] - 'a' + 1; j < 26; j++) {
            if (used[j]) {
                res[i] = 'a' + j;
                for (int x = i + 1; x <= k; x++) {
                    res[x] = res[0];
                }
                goto Break;
            }
        }
    }
    Break:
    if (k > n) {
        for (int i = n + 1; i <= k; i++)  {
            res[i] = res[0];
        }
    }
    printf("%s\n", res + 1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    ok[n] = true;
    for (int i = n - 1; i >= 1; i--) {
        ok[i] = ok[i + 1] && (s[i] >= s[i + 1]);
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
        if (flag) {
            for (int j = 0; j < 26; j++) {
                if (used[j]) {
                    res[i] = 'a' + j;
                    break;
                }
            }
            continue;
        }
        if ((i < n && (ok[i] || !ok[i + 1]))) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = 1;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = 1; i <= n; i++) {
            res[i] = s[i];
        }
        for (int i = n + 1; i <= k; i++)  {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    ok[n] = true;
    for (int i = n - 1; i >= 1; i--) {
        ok[i] = ok[i + 1] && (s[i] >= s[i + 1]);
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
        if (i < n && (flag || ok[i] || !ok[i + 1])) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = 1;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = n; i <= k; i++) {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    ok[n] = true;
    for (int i = n - 1; i >= 1; i--) {
        ok[i] = ok[i + 1] && (s[i] >= s[i + 1]);
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
        if (flag) {
            for (int j = 0; j < 26; j++) {
                if (used[j]) {
                    res[i] = 'a' + j;
                    break;
                }
            }
            continue;
        }
        if ((i < n && (ok[i] || !ok[i + 1]))) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = 1;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = n; i <= k; i++) {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26], ok[maxn];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    ok[n] = true;
    for (int i = n - 1; i >= 1; i--) {
        ok[i] = ok[i + 1] && (s[i] >= s[i + 1]);
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
        if (flag) {
            for (int j = 0; j < 26; j++) {
                if (used[j]) {
                    res[i] = 'a' + j;
                    break;
                }
            }
            continue;
        }
        char ch;
        for (int j = 25; j >= 0; j--) {
            if (used[j]) {
                ch = 'a' + j;
                break;
            }
        }
        if (i < n && (ch > s[i + 1] || !ok[i + 1])) {
            res[i] = s[i];
        } else {
            bool ok = false;
            for (int j = (flag ? 0 : s[i] - 'a' + 1); j < 26; j++) {
                if (used[j]) {
                    res[i] = j + 'a';
                    flag = 1;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                res[i] = 'a';
            }
        }
    }
    if (k > n) {
        char ch;
        for (int i = 0; i < 26; i++) {
            if (used[i]) {
                ch = 'a' + i;
                break;
            }
        }
        for (int i = 1; i <= n; i++) {
            res[i] = s[i];
        }
        for (int i = n + 1; i <= k; i++)  {
            res[i] = ch;
        }
    } else if (k < n) {
        bool change = true;
        for (int i = 1; i <= k; i++) {
            if (res[i] > s[i]) {
                change = false;
                break;
            }
        }
        if (change) {
            for (int i = k; i >= 1; i--) {
                bool found = false;
                for (int j = res[i] - 'a' + 1; j < 26; j++) {
                    if (used[j]) {
                        found = true;
                        res[i] = 'a' + j;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= k; i++) {
        putchar(res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int n, k;
char s[maxn], res[maxn];
bool used[26];

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
        used[s[i] - 'a'] = true;
    }
    for (int i = 26; i >= 0; i--) {
        if (used[i]) {
            for (int j = 1; j <= k; j++) {
                putchar(i + 'a');
            }
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef short int int16;
typedef long double ldouble;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

typedef pair < int , int > ipair;
typedef pair < LL , LL > lpair;
typedef map < int,int > imap;
typedef map < LL , LL > lmap;
typedef vector < int > ivector;
typedef vector < LL > lvector;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<class T> void _R( T &x ) { cin>>x; }

void _R( int &x ) { scanf("%d",&x); }
void _R( LL &x ) { scanf("%i64d",&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }

const int size = 1e5 + 2;
const double eps = 0.0001;
const ldouble PI = 3.1415926535897932384626433832795;
const LL  MOD = 1000000007;
const LL INF = 1LL << 60;
const LL MAX5 = 100001;
const LL MAX6 = 1000001;

#define MEMS(a,b) memset((a),(b),sizeof(a))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))
#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))
#define all(x) (x).begin(), (x).end()
#define rep(i,a,n) for (long long i=a;i<n;++i)
#define per(i,n,a) for (long long i=n-1;i>=a;--i)
#define read(a,n) for(LL i=0;i<n;++i)cin>>a[i];
#define vout for(int i=0;i<res.size();++i)cout<<res[i];
#define reunique(v) v.resize(unique(v.begin(), v.end()) - v.begin())
#define res(); cout<<res;
void solution();
void include_file();
LL bin_search(LL left, LL right);

int main(){
ios_base::sync_with_stdio(false);
//srand(time(0));
//include_file();
solution();
return 0;
}
void include_file(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
inline bool isPrime(LL n) {
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return false;
    return true;
}
string ekv(string a) {
    if (a.size() & 1)return a;
    string x = ekv(a.substr(0, a.size() / 2));
    string y = ekv(a.substr(a.size() / 2));
    return min(x + y, y + x);
}
LL cubic_root(LL x) {
    LL l = 0, r = MAX6;
    while (l != r) {
        LL m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
float FastInvSqrt(float x) {
	//   1/sqrt(X)
  float xhalf = 0.5f * x;
  int i = *(int*)&x;  // i?aanoaaei aeou float a aeaa oaeiai ?enea
  i = 0x5f3759df - (i >> 1);  // eaeiai ?a?oa caanu i?ienoiaeo ?
  x = *(float*)&i;
  x = x*(1.5f-(xhalf*x*x));
  return x;
}
LL gcd(LL a,LL b)
{
  if(a==0)return b;
  return gcd(b%a,a);
}
LL lcm(LL a, LL b)
{
  return a/gcd(a, b)*b;
}

void yes()
{
	cout<<"YES";
}
void no()
{
	cout<<"NO";
}
void yes(bool res)
{
	if(res)
	cout<<"YES";
	else cout<<"NO";
}
void dabl(double x)
{
	printf("%.10lf",x);
}
namespace bits
{
	template<typename X> inline X MAX(const X& a, const X& b)
{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}
template<typename X> inline X MIN(const X& a, const X& b)
{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}

//i?iaa?ea ia noaiaiu 2
bool check2(const LL n)
{
	return 	n > 0 && (n & (n - 1));
}
//inoaoie io aaeaiey 2^n ia m
LL ostatok2(const LL n, const LL m)
{
	return m & (n-1);
}
template<typename X>
void SWAP(X &a, X &b)
{
	a^=b;
	b^=a;
	a^=b;
}

size_t count_1_in_LL(unsigned long long n)
{
    std::size_t i(0);
    for (;n;++i) n&=n-1;
    return i;
}
}
vector <vector<int> > g;
///////////////////SOLUTION

void solution()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	set<char> sy;
	rep(i,0,n)
	sy.insert(s[i]);
	string t="";
	if(k>n)
	{
		t=s;
		rep(i,n,k)
		t+=(*sy.begin());
	}
	else if(n>k)
	{
		rep(i,0,k)
		t+=s[i];
		int pos=k-1;
		while(1)
		{
			bool b=0;
			for(auto x:s)
			if(x>t[pos]){t[pos]=x;b=1;break;}
			if(b)break;
			else pos--;
		}
	}
	else
	{
		t=s;
		for(int i=n-1;i>=0;--i)
		{
			auto h=sy.end();
			--h;
			auto hh=h;
			--hh;
			if(t[i]!=*h)
			{
				char vvv;
				for(auto y:sy)
				if(y>t[i]){vvv=y;break;}
				t[i]=vvv;
				rep(j,i+1,n)
					t[j]=(*sy.begin());
				break;
			}
		}
	}
	cout<<t;
}
///////////////////SOLUTION


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef short int int16;
typedef long double ldouble;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

typedef pair < int , int > ipair;
typedef pair < LL , LL > lpair;
typedef map < int,int > imap;
typedef map < LL , LL > lmap;
typedef vector < int > ivector;
typedef vector < LL > lvector;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<class T> void _R( T &x ) { cin>>x; }

void _R( int &x ) { scanf("%d",&x); }
void _R( LL &x ) { scanf("%i64d",&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }

const int size = 1e5 + 2;
const double eps = 0.0001;
const ldouble PI = 3.1415926535897932384626433832795;
const LL  MOD = 1000000007;
const LL INF = 1LL << 60;
const LL MAX5 = 100001;
const LL MAX6 = 1000001;

#define MEMS(a,b) memset((a),(b),sizeof(a))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))
#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))
#define all(x) (x).begin(), (x).end()
#define rep(i,a,n) for (long long i=a;i<n;++i)
#define per(i,n,a) for (long long i=n-1;i>=a;--i)
#define read(a,n) for(LL i=0;i<n;++i)cin>>a[i];
#define vout for(int i=0;i<res.size();++i)cout<<res[i];
#define reunique(v) v.resize(unique(v.begin(), v.end()) - v.begin())
#define res(); cout<<res;
void solution();
void include_file();
LL bin_search(LL left, LL right);

int main(){
ios_base::sync_with_stdio(false);
//srand(time(0));
//include_file();
solution();
return 0;
}
void include_file(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
inline bool isPrime(LL n) {
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return false;
    return true;
}
string ekv(string a) {
    if (a.size() & 1)return a;
    string x = ekv(a.substr(0, a.size() / 2));
    string y = ekv(a.substr(a.size() / 2));
    return min(x + y, y + x);
}
LL cubic_root(LL x) {
    LL l = 0, r = MAX6;
    while (l != r) {
        LL m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
float FastInvSqrt(float x) {
	//   1/sqrt(X)
  float xhalf = 0.5f * x;
  int i = *(int*)&x;  // i?aanoaaei aeou float a aeaa oaeiai ?enea
  i = 0x5f3759df - (i >> 1);  // eaeiai ?a?oa caanu i?ienoiaeo ?
  x = *(float*)&i;
  x = x*(1.5f-(xhalf*x*x));
  return x;
}
LL gcd(LL a,LL b)
{
  if(a==0)return b;
  return gcd(b%a,a);
}
LL lcm(LL a, LL b)
{
  return a/gcd(a, b)*b;
}

void yes()
{
	cout<<"YES";
}
void no()
{
	cout<<"NO";
}
void yes(bool res)
{
	if(res)
	cout<<"YES";
	else cout<<"NO";
}
void dabl(double x)
{
	printf("%.10lf",x);
}
namespace bits
{
	template<typename X> inline X MAX(const X& a, const X& b)
{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}
template<typename X> inline X MIN(const X& a, const X& b)
{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}

//i?iaa?ea ia noaiaiu 2
bool check2(const LL n)
{
	return 	n > 0 && (n & (n - 1));
}
//inoaoie io aaeaiey 2^n ia m
LL ostatok2(const LL n, const LL m)
{
	return m & (n-1);
}
template<typename X>
void SWAP(X &a, X &b)
{
	a^=b;
	b^=a;
	a^=b;
}

size_t count_1_in_LL(unsigned long long n)
{
    std::size_t i(0);
    for (;n;++i) n&=n-1;
    return i;
}
}
vector <vector<int> > g;
///////////////////SOLUTION

void solution()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	set<char> sy;
	rep(i,0,n)
	sy.insert(s[i]);
	string t="";
	if(k>n)
	{
		t=s;
		rep(i,n,k)
		t+=(*sy.begin());
	}
	else if(n>k)
	{
		rep(i,0,k)
		t+=s[i];
		for(auto x:s)
		if(x>t[k-1]){t[k-1]=x;break;}
	}
	else
	{
		t=s;
		for(int i=n-1;i>=0;--i)
		{
			auto h=sy.end();
			--h;
			auto hh=h;
			--hh;
			if(s[i]==*hh)
			{
				t[i]=(*h);
				rep(j,i+1,n)
					t[j]=(*sy.begin());
				break;
			}
		}
	}
	cout<<t;
}
///////////////////SOLUTION


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef short int int16;
typedef long double ldouble;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

typedef pair < int , int > ipair;
typedef pair < LL , LL > lpair;
typedef map < int,int > imap;
typedef map < LL , LL > lmap;
typedef vector < int > ivector;
typedef vector < LL > lvector;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<class T> void _R( T &x ) { cin>>x; }

void _R( int &x ) { scanf("%d",&x); }
void _R( LL &x ) { scanf("%i64d",&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }

const int size = 1e5 + 2;
const double eps = 0.0001;
const ldouble PI = 3.1415926535897932384626433832795;
const LL  MOD = 1000000007;
const LL INF = 1LL << 60;
const LL MAX5 = 100001;
const LL MAX6 = 1000001;

#define MEMS(a,b) memset((a),(b),sizeof(a))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))
#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))
#define all(x) (x).begin(), (x).end()
#define rep(i,a,n) for (long long i=a;i<n;++i)
#define per(i,n,a) for (long long i=n-1;i>=a;--i)
#define read(a,n) for(LL i=0;i<n;++i)cin>>a[i];
#define vout for(int i=0;i<res.size();++i)cout<<res[i];
#define reunique(v) v.resize(unique(v.begin(), v.end()) - v.begin())
#define res(); cout<<res;
void solution();
void include_file();
LL bin_search(LL left, LL right);

int main(){
ios_base::sync_with_stdio(false);
//srand(time(0));
//include_file();
solution();
return 0;
}
void include_file(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
inline bool isPrime(LL n) {
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return false;
    return true;
}
string ekv(string a) {
    if (a.size() & 1)return a;
    string x = ekv(a.substr(0, a.size() / 2));
    string y = ekv(a.substr(a.size() / 2));
    return min(x + y, y + x);
}
LL cubic_root(LL x) {
    LL l = 0, r = MAX6;
    while (l != r) {
        LL m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
float FastInvSqrt(float x) {
	//   1/sqrt(X)
  float xhalf = 0.5f * x;
  int i = *(int*)&x;  // i?aanoaaei aeou float a aeaa oaeiai ?enea
  i = 0x5f3759df - (i >> 1);  // eaeiai ?a?oa caanu i?ienoiaeo ?
  x = *(float*)&i;
  x = x*(1.5f-(xhalf*x*x));
  return x;
}
LL gcd(LL a,LL b)
{
  if(a==0)return b;
  return gcd(b%a,a);
}
LL lcm(LL a, LL b)
{
  return a/gcd(a, b)*b;
}

void yes()
{
	cout<<"YES";
}
void no()
{
	cout<<"NO";
}
void yes(bool res)
{
	if(res)
	cout<<"YES";
	else cout<<"NO";
}
void dabl(double x)
{
	printf("%.10lf",x);
}
namespace bits
{
	template<typename X> inline X MAX(const X& a, const X& b)
{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}
template<typename X> inline X MIN(const X& a, const X& b)
{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}

//i?iaa?ea ia noaiaiu 2
bool check2(const LL n)
{
	return 	n > 0 && (n & (n - 1));
}
//inoaoie io aaeaiey 2^n ia m
LL ostatok2(const LL n, const LL m)
{
	return m & (n-1);
}
template<typename X>
void SWAP(X &a, X &b)
{
	a^=b;
	b^=a;
	a^=b;
}

size_t count_1_in_LL(unsigned long long n)
{
    std::size_t i(0);
    for (;n;++i) n&=n-1;
    return i;
}
}
vector <vector<int> > g;
///////////////////SOLUTION

void solution()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	set<char> sy;
	rep(i,0,n)
	sy.insert(s[i]);
	string t="";
	if(k>n)
	{
		t=s;
		rep(i,n,k)
		t+=(*sy.begin());
	}
	else if(n>k)
	{
		rep(i,0,k)
		t+=s[i];
		int pos=k-1;
		while(1)
		{
			bool b=0;
			for(auto x:s)
			if(x>t[pos]){t[pos]=x;b=1;break;}
			if(b)break;
			else pos--;
		}
	}
	else
	{
		t=s;
		for(int i=n-1;i>=0;--i)
		{
			auto h=sy.end();
			--h;
			auto hh=h;
			--hh;
			if(s[i]==*hh)
			{
				t[i]=(*h);
				rep(j,i+1,n)
					t[j]=(*sy.begin());
				break;
			}
		}
	}
	cout<<t;
}
///////////////////SOLUTION


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef short int int16;
typedef long double ldouble;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

typedef pair < int , int > ipair;
typedef pair < LL , LL > lpair;
typedef map < int,int > imap;
typedef map < LL , LL > lmap;
typedef vector < int > ivector;
typedef vector < LL > lvector;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<class T> void _R( T &x ) { cin>>x; }

void _R( int &x ) { scanf("%d",&x); }
void _R( LL &x ) { scanf("%i64d",&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }

const int size = 1e5 + 2;
const double eps = 0.0001;
const ldouble PI = 3.1415926535897932384626433832795;
const LL  MOD = 1000000007;
const LL INF = 1LL << 60;
const LL MAX5 = 100001;
const LL MAX6 = 1000001;

#define MEMS(a,b) memset((a),(b),sizeof(a))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))
#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))
#define all(x) (x).begin(), (x).end()
#define rep(i,a,n) for (long long i=a;i<n;++i)
#define per(i,n,a) for (long long i=n-1;i>=a;--i)
#define read(a,n) for(LL i=0;i<n;++i)cin>>a[i];
#define vout for(int i=0;i<res.size();++i)cout<<res[i];
#define reunique(v) v.resize(unique(v.begin(), v.end()) - v.begin())
#define res(); cout<<res;
void solution();
void include_file();
LL bin_search(LL left, LL right);

int main(){
ios_base::sync_with_stdio(false);
//srand(time(0));
//include_file();
solution();
return 0;
}
void include_file(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
inline bool isPrime(LL n) {
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return false;
    return true;
}
string ekv(string a) {
    if (a.size() & 1)return a;
    string x = ekv(a.substr(0, a.size() / 2));
    string y = ekv(a.substr(a.size() / 2));
    return min(x + y, y + x);
}
LL cubic_root(LL x) {
    LL l = 0, r = MAX6;
    while (l != r) {
        LL m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
float FastInvSqrt(float x) {
	//   1/sqrt(X)
  float xhalf = 0.5f * x;
  int i = *(int*)&x;  // i?aanoaaei aeou float a aeaa oaeiai ?enea
  i = 0x5f3759df - (i >> 1);  // eaeiai ?a?oa caanu i?ienoiaeo ?
  x = *(float*)&i;
  x = x*(1.5f-(xhalf*x*x));
  return x;
}
LL gcd(LL a,LL b)
{
  if(a==0)return b;
  return gcd(b%a,a);
}
LL lcm(LL a, LL b)
{
  return a/gcd(a, b)*b;
}

void yes()
{
	cout<<"YES";
}
void no()
{
	cout<<"NO";
}
void yes(bool res)
{
	if(res)
	cout<<"YES";
	else cout<<"NO";
}
void dabl(double x)
{
	printf("%.10lf",x);
}
namespace bits
{
	template<typename X> inline X MAX(const X& a, const X& b)
{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}
template<typename X> inline X MIN(const X& a, const X& b)
{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}

//i?iaa?ea ia noaiaiu 2
bool check2(const LL n)
{
	return 	n > 0 && (n & (n - 1));
}
//inoaoie io aaeaiey 2^n ia m
LL ostatok2(const LL n, const LL m)
{
	return m & (n-1);
}
template<typename X>
void SWAP(X &a, X &b)
{
	a^=b;
	b^=a;
	a^=b;
}

size_t count_1_in_LL(unsigned long long n)
{
    std::size_t i(0);
    for (;n;++i) n&=n-1;
    return i;
}
}
vector <vector<int> > g;
///////////////////SOLUTION

void solution()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	set<char> sy;
	rep(i,0,n)
	sy.insert(s[i]);
	string t="";
	if(k>n)
	{
		t=s;
		rep(i,k-n+1,k)
		t+=(*sy.begin());
	}
	else if(n>k)
	{
		rep(i,0,k)
		t+=s[i];
		for(auto x:s)
		if(x>t[k-1]){t[k-1]=x;break;}
	}
	else
	{
		t=s;
		for(int i=n-1;i>=0;--i)
		{
			auto h=sy.end();
			--h;
			auto hh=h;
			--hh;
			if(s[i]==*hh)
			{
				t[i]=(*h);
				rep(j,i+1,n)
					t[j]=(*sy.begin());
				break;
			}
		}
	}
	cout<<t;
}
///////////////////SOLUTION


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef short int int16;
typedef long double ldouble;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

typedef pair < int , int > ipair;
typedef pair < LL , LL > lpair;
typedef map < int,int > imap;
typedef map < LL , LL > lmap;
typedef vector < int > ivector;
typedef vector < LL > lvector;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<class T> void _R( T &x ) { cin>>x; }

void _R( int &x ) { scanf("%d",&x); }
void _R( LL &x ) { scanf("%i64d",&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }

const int size = 1e5 + 2;
const double eps = 0.0001;
const ldouble PI = 3.1415926535897932384626433832795;
const LL  MOD = 1000000007;
const LL INF = 1LL << 60;
const LL MAX5 = 100001;
const LL MAX6 = 1000001;

#define MEMS(a,b) memset((a),(b),sizeof(a))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))
#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))
#define all(x) (x).begin(), (x).end()
#define rep(i,a,n) for (long long i=a;i<n;++i)
#define per(i,n,a) for (long long i=n-1;i>=a;--i)
#define read(a,n) for(LL i=0;i<n;++i)cin>>a[i];
#define vout for(int i=0;i<res.size();++i)cout<<res[i];
#define reunique(v) v.resize(unique(v.begin(), v.end()) - v.begin())
#define res(); cout<<res;
void solution();
void include_file();
LL bin_search(LL left, LL right);

int main(){
ios_base::sync_with_stdio(false);
//srand(time(0));
//include_file();
solution();
return 0;
}
void include_file(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
inline bool isPrime(LL n) {
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return false;
    return true;
}
string ekv(string a) {
    if (a.size() & 1)return a;
    string x = ekv(a.substr(0, a.size() / 2));
    string y = ekv(a.substr(a.size() / 2));
    return min(x + y, y + x);
}
LL cubic_root(LL x) {
    LL l = 0, r = MAX6;
    while (l != r) {
        LL m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
float FastInvSqrt(float x) {
	//   1/sqrt(X)
  float xhalf = 0.5f * x;
  int i = *(int*)&x;  // i?aanoaaei aeou float a aeaa oaeiai ?enea
  i = 0x5f3759df - (i >> 1);  // eaeiai ?a?oa caanu i?ienoiaeo ?
  x = *(float*)&i;
  x = x*(1.5f-(xhalf*x*x));
  return x;
}
LL gcd(LL a,LL b)
{
  if(a==0)return b;
  return gcd(b%a,a);
}
LL lcm(LL a, LL b)
{
  return a/gcd(a, b)*b;
}

void yes()
{
	cout<<"YES";
}
void no()
{
	cout<<"NO";
}
void yes(bool res)
{
	if(res)
	cout<<"YES";
	else cout<<"NO";
}
void dabl(double x)
{
	printf("%.10lf",x);
}
namespace bits
{
	template<typename X> inline X MAX(const X& a, const X& b)
{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}
template<typename X> inline X MIN(const X& a, const X& b)
{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}

//i?iaa?ea ia noaiaiu 2
bool check2(const LL n)
{
	return 	n > 0 && (n & (n - 1));
}
//inoaoie io aaeaiey 2^n ia m
LL ostatok2(const LL n, const LL m)
{
	return m & (n-1);
}
template<typename X>
void SWAP(X &a, X &b)
{
	a^=b;
	b^=a;
	a^=b;
}

size_t count_1_in_LL(unsigned long long n)
{
    std::size_t i(0);
    for (;n;++i) n&=n-1;
    return i;
}
}
vector <vector<int> > g;
///////////////////SOLUTION

void solution()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	set<char> sy;
	rep(i,0,n)
	sy.insert(s[i]);
	string t="";
	if(k>n)
	{
		t=s;
		rep(i,n,k)
		t+=(*sy.begin());
	}
	else if(n>k)
	{
		rep(i,0,k)
		t+=s[i];
		int pos=k-1;
		while(1)
		{
			bool b=0;
			for(auto x:sy)
			if(x>t[pos]){t[pos]=x;b=1;break;}
			if(b)break;
			else pos--;
		}
		for(int i=pos+1;i<k;++i)t[i]=(*sy.begin());
	}
	else
	{
		t=s;
		for(int i=n-1;i>=0;--i)
		{
			auto h=sy.end();
			--h;
			auto hh=h;
			--hh;
			if(t[i]!=*h)
			{
				char vvv;
				for(auto y:sy)
				if(y>t[i]){vvv=y;break;}
				t[i]=vvv;
				rep(j,i+1,n)
					t[j]=(*sy.begin());
				break;
			}
		}
	}
	cout<<t;
}
///////////////////SOLUTION


#include<bits/stdc++.h>
using namespace std;
int n,k,arr[100],p,it;
string s,has;
vector<int> v,sim;
int main()
{
	cin>>n>>k>>s;
	for(int i=0;i<s.size();i++) arr[s[i]-'a'+1]++;
	for(int i=1;i<=26;i++) if(arr[i]>0) v.push_back(i);
	sort(v.begin(),v.end());
	int t=v.size();
	if(k>n)
	{
		has+=s;
		for(int i=1;i<=k-n;i++) has+=char(v[0]-1+'a');
		cout<<has<<endl;
	}
	else
	{
		//cout<<v[t-1]<<endl;
		char x=char(v[t-1]+96);
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=char(v[t-1]+96)) sim.push_back(i);
		}
		for(int i=k-1;i>=0;i--)
		{
			if(s[i]!=x)
			{
				it=i;
				break;
			}
		}
		//cout<<it<<endl;
		for(int i=0;i<v.size();i++)
		{
			if(s[it]==char(v[i]+96))
			{
				p=i+1;
				break;
			}
		}
		//cout<<p<<endl<<"====="<<endl;
		for(int i=0;i<it;i++) has+=s[i];
		//cout<<v[p]<<endl;
		has+=char(v[p]+96);
		for(int i=it+1;i<k;i++) has+='a';
		cout<<has<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,k,arr[100],p,it;
string s,has;
vector<int> v,sim;
int main()
{
	cin>>n>>k>>s;
	for(int i=0;i<s.size();i++) arr[s[i]-'a'+1]++;
	for(int i=1;i<=26;i++) if(arr[i]>0) v.push_back(i);
	sort(v.begin(),v.end());
	int t=v.size();
	if(k>n)
	{
		has+=s;
		for(int i=1;i<=k-n;i++) has+=char(v[0]-1+'a');
		cout<<has<<endl;
	}
	else
	{
		//cout<<v[t-1]<<endl;
		char x=char(v[t-1]+96);
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=char(v[t-1]+96)) sim.push_back(i);
		}
		for(int i=k-1;i>=0;i--)
		{
			if(s[i]!=x)
			{
				it=i;
				break;
			}
		}
		//cout<<it<<endl;
		for(int i=0;i<v.size();i++)
		{
			if(s[it]==char(v[i]+96))
			{
				p=i+1;
				break;
			}
		}
		//cout<<p<<endl<<"====="<<endl;
		for(int i=0;i<it;i++) has+=s[i];
		//cout<<v[p]<<endl;
		has+=char(v[p]+96);
		for(int i=it+1;i<k;i++) has+=char(v[0]-1+'a');
		cout<<has<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,k,arr[100],p,it;
string s,has;
vector<int> v,sim;
int main()
{
	cin>>n>>k>>s;
	for(int i=0;i<s.size();i++) arr[s[i]-'a'+1]++;
	for(int i=1;i<=26;i++) if(arr[i]>0) v.push_back(i);
	sort(v.begin(),v.end());
	int t=v.size();
	if(k>n)
	{
		has+=s;
		for(int i=1;i<=k-n;i++) has+='a';
		cout<<has<<endl;
	}
	else
	{
		//cout<<v[t-1]<<endl;
		char x=char(v[t-1]+96);
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=char(v[t-1]+96)) sim.push_back(i);
		}
		for(int i=k-1;i>=0;i--)
		{
			if(s[i]!=x)
			{
				it=i;
				break;
			}
		}
		//cout<<it<<endl;
		for(int i=0;i<v.size();i++)
		{
			if(s[it]==char(v[i]+96))
			{
				p=i+1;
				break;
			}
		}
		//cout<<p<<endl<<"====="<<endl;
		for(int i=0;i<it;i++) has+=s[i];
		//cout<<v[p]<<endl;
		has+=char(v[p]+96);
		for(int i=it+1;i<k;i++) has+='a';
		cout<<has<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,k;
string s,has;
char chr='a';
int main()
{
	cin>>n>>k>>s;
	for(int i=0;i<s.size();i++)
	{
		chr=max(chr,s[i]);
	}
	for(int i=1;i<=k;i++) has+=chr;
	cout<<has<<endl;
}


#include <bits/stdc++.h>
using namespace std;

template <class T> int size(const T &x) {return x.size();}
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;}

#define F first
#define S second
#define PB push_back
#define endl '\n'
#define rep(i, a, b) for(__typeof(a) i=a; i<(b); i++)
#define iter(it, c) for(__typeof((c).begin()) it=(c).begin(); \
 it != (c).end(); it++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;

const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double PI = acos(-1);

char next(char c, set<char> &v) {

    set<char>::iterator it;
    it = upper_bound(v.begin(), v.end(), c);

    if(it == v.end()) return '!';

    return *it;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif // LOCAL

    int n, t;
    string s, p;

    cin >> n >> t >> s;
    set<char> S(s.begin(), s.end());

    if(t > n) {

        p = s;
        rep(i, 0, n - t);
        p.PB('a');

    } else  {
        if(t < n)
            p = s.substr(0, t);
        else{
            // cout << "here" << endl;
            p = s;
        }

        int idx = t - 1;
        while(idx >= 0) {
            char nxt = next(p[idx], S);

            if(nxt == '!') {
                p[idx] = 'a';
                idx--;
            } else {
                p[idx] = nxt;
                break;
            }

        }

    }

    cout << p << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <class T> int size(const T &x) {return x.size();}
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;}

#define F first
#define S second
#define PB push_back
#define endl '\n'
#define rep(i, a, b) for(__typeof(a) i=a; i<(b); i++)
#define iter(it, c) for(__typeof((c).begin()) it=(c).begin(); \
 it != (c).end(); it++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;

const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double PI = acos(-1);

char next(char c, set<char> &v) {

    set<char>::iterator it;
    it = upper_bound(v.begin(), v.end(), c);

    if(it == v.end()) return '!';

    return *it;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif // LOCAL

    int n, t;
    string s, p;

    cin >> n >> t >> s;
    set<char> S(s.begin(), s.end());

    if(t > n) {

        p = s;
        rep(i, 0, n - t);
        p.PB(*S.begin());

    } else  {
        if(t < n)
            p = s.substr(0, t);
        else{
            // cout << "here" << endl;
            p = s;
        }

        int idx = t - 1;
        while(idx >= 0) {
            char nxt = next(p[idx], S);

            if(nxt == '!') {
                p[idx] = 'a';
                idx--;
            } else {
                p[idx] = nxt;
                break;
            }

        }

    }

    cout << p << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <class T> int size(const T &x) {return x.size();}
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;}

#define F first
#define S second
#define PB push_back
#define endl '\n'
#define rep(i, a, b) for(__typeof(a) i=a; i<(b); i++)
#define iter(it, c) for(__typeof((c).begin()) it=(c).begin(); \
 it != (c).end(); it++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;

const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double PI = acos(-1);

char next(char c, set<char> &v) {

    set<char>::iterator it;
    it = upper_bound(v.begin(), v.end(), c);

    if(it == v.end()) return '!';

    return *it;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif // LOCAL

    int n, t;
    string s, p;

    cin >> n >> t >> s;
    set<char> S(s.begin(), s.end());

    if(t > n) {

        p = s;
        rep(i, 0, n - t);
        p.PB('a');

    } else  {
        if(t < n)
            p = s.substr(0, t);
        else{
            cout << "here" << endl;
            p = s;
        }

        int idx = t - 1;
        while(idx >= 0) {
            char nxt = next(p[idx], S);

            if(nxt == '!') {
                p[idx] = 'a';
                idx--;
            } else {
                p[idx] = nxt;
                break;
            }

        }

    }

    cout << p << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <class T> int size(const T &x) {return x.size();}
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;}

#define F first
#define S second
#define PB push_back
#define endl '\n'
#define rep(i, a, b) for(__typeof(a) i=a; i<(b); i++)
#define iter(it, c) for(__typeof((c).begin()) it=(c).begin(); \
 it != (c).end(); it++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;

const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double PI = acos(-1);

char next(char c, set<char> &v) {

    set<char>::iterator it;
    it = upper_bound(v.begin(), v.end(), c);

    if(it == v.end()) return '!';

    return *it;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif // LOCAL

    int n, t;
    string s, p;

    cin >> n >> t >> s;
    set<char> S(s.begin(), s.end());

    if(t > n) {

        p = s;
        rep(i, 0, t - n)
            p.PB(*S.begin());

    } else  {
        if(t < n)
            p = s.substr(0, t);
        else{
            // cout << "here" << endl;
            p = s;
        }

        int idx = t - 1;
        while(idx >= 0) {
            char nxt = next(p[idx], S);

            if(nxt == '!') {
                p[idx] = 'a';
                idx--;
            } else {
                p[idx] = nxt;
                break;
            }

        }

    }

    cout << p << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <class T> int size(const T &x) {return x.size();}
template <class T> T mod(T a, T b) { return (b + (a % b)) % b;}

#define F first
#define S second
#define PB push_back
#define endl '\n'
#define rep(i, a, b) for(__typeof(a) i=a; i<(b); i++)
#define iter(it, c) for(__typeof((c).begin()) it=(c).begin(); \
 it != (c).end(); it++)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;

const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double PI = acos(-1);

char next(char c, set<char> &v) {

    set<char>::iterator it;
    it = upper_bound(v.begin(), v.end(), c);

    if(it == v.end()) return '!';

    return *it;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif // LOCAL

    int n, t;
    string s, p;

    cin >> n >> t >> s;
    set<char> S(s.begin(), s.end());

    if(t > n) {

        p = s;
        rep(i, 0, t - n)
            p.PB(*S.begin());

    } else  {
        if(t < n)
            p = s.substr(0, t);
        else{
            // cout << "here" << endl;
            p = s;
        }

        int idx = t - 1;
        while(idx >= 0) {
            char nxt = next(p[idx], S);

            if(nxt == '!') {
                p[idx] = *S.begin();
                idx--;
            } else {
                p[idx] = nxt;
                break;
            }

        }

    }

    cout << p << endl;
    return 0;
}


	#include <bits/stdc++.h>
	#define mod int(1e9+7)
	#define INF 1e18
	#define int long long
	using namespace std;
	const int N=2000;
	signed main() {
		ios_base::sync_with_stdio(false);
	    cin.tie(0);cout.tie(0);
	   //freopen("mushrooms.in","r",stdin);
	  // freopen("mushrooms.out","w",stdout);
		int n,k;
		bool flag;
		string s,ans;
		cin >>n>>k;
		cin >>s;
		set<char>q;
		set<char>::iterator sim;
		for (int i=0;i<n;i++)q.insert(s[i]);
		if (k>n)
		{
			for (int i=0;i<k-n;i++)s+=*q.begin();
			cout <<s;

			return 0;
		}
		for (int i=min(k-1,n-1);i>=0;i--)
		{
			if (flag)ans+=s[i];
			else
			{
				 sim=q.upper_bound(s[i]);
				if (sim==q.end())
				{
				ans+=*q.begin();continue;
				}
				ans+=*sim;
				flag=true;
			}
		}
		reverse(ans.begin(),ans.end());
		cout <<ans;
		return 0;
	}


	#include <bits/stdc++.h>
	#define mod int(1e9+7)
	#define INF 1e18
	#define int long long
	using namespace std;
	const int N=2000;
	signed main() {
		ios_base::sync_with_stdio(false);
	    cin.tie(0);cout.tie(0);
	   //freopen("mushrooms.in","r",stdin);
	  // freopen("mushrooms.out","w",stdout);
		int n,k;
		bool flag=false;
		string s,ans;
		cin >>n>>k;
		cin >>s;
		set<char>q;
		set<char>::iterator sim;
		for (int i=0;i<n;i++)q.insert(s[i]);
		for (int i=k-1;i>=0;i--)
		{
			if (flag)ans+=s[i];
			else
			{
				 sim=q.upper_bound(s[i]);
				if (sim==q.end())
				{
				ans+=*q.begin();continue;
				}
				ans+=*sim;
				flag=true;
			}
		}
		reverse(ans.begin(),ans.end());
		cout <<ans;
		return 0;
	}


	#include <bits/stdc++.h>
	#define mod int(1e9+7)
	#define INF 1e18
	#define int long long
	using namespace std;
	const int N=2000;
	signed main() {
		ios_base::sync_with_stdio(false);
	    cin.tie(0);cout.tie(0);
	   //freopen("mushrooms.in","r",stdin);
	  // freopen("mushrooms.out","w",stdout);
		int n,k;
		bool flag;
		string s,ans;
		cin >>n>>k;
		cin >>s;
		set<char>q;
		set<char>::iterator sim;
		for (int i=0;i<n;i++)q.insert(s[i]);
		for (int i=k-1;i>=0;i--)
		{
			if (flag)ans+=s[i];
			else
			{
				 sim=q.upper_bound(s[i]);
				if (sim==q.end())
				{
				ans+=*q.begin();continue;
				}
				ans+=*sim;
				flag=true;
			}
		}
		reverse(ans.begin(),ans.end());
		cout <<ans;
		return 0;
	}


	#include <bits/stdc++.h>
	#define mod int(1e9+7)
	#define INF 1e18
	#define int long long
	using namespace std;
	const int N=2000;
	signed main() {
		ios_base::sync_with_stdio(false);
	    cin.tie(0);cout.tie(0);
	   //freopen("mushrooms.in","r",stdin);
	  // freopen("mushrooms.out","w",stdout);
		int n,k;
		bool flag=false;
		string s,ans;
		cin >>n>>k;
		cin >>s;
		set<char>q;
		set<char>::iterator sim;
		for (int i=0;i<n;i++)q.insert(s[i]);
		if (k>n)
		{
			for (int i=0;i<k-n;i++)s+=*q.begin();
			cout <<s;

			return 0;
		}
		for (int i=min(k-1,n-1);i>=0;i--)
		{
			if (flag)ans+=s[i];
			else
			{
				 sim=q.upper_bound(s[i]);
				if (sim==q.end())
				{
				ans+=*q.begin();continue;
				}
				ans+=*sim;
				flag=true;
			}
		}
		reverse(ans.begin(),ans.end());
		cout <<ans;
		return 0;
	}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int vis[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    //IOS
    ms(vis, 0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0; i<n; i++) {
        vis[s[i]-'a'] = 1;
    }
    int Min = inf, Max = -1;
    for(int i = 0; i<26; i++) {
        if(vis[i]) {
            Min = min(Min, i);
            Max = max(Max, i);
        }
    }
    if(k<=n) {
        int pos;
        for(int i = k-1; i>=0; i--) {
            if(s[i]-'a'<Max) {
                pos = i;
                break;
            }
        }
        for(int i = 0; i<pos; i++) {
            printf("%c", 'a'+Min);
        }
        printf("%c", 'a'+Max);
        for(int i = pos+1; i<k; i++) {
            printf("%c", 'a'+Min);
        }
    } else {
        cout << s;
        for(int i = 0; i<k-n; i++) {
            printf("%c", 'a'+Min);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int vis[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    ms(vis, 0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0;i<n;i++){
        vis[s[i]-'a'] = 1;
    }
    char ans;
    for(int i = 26;i>=0;i--){
        if(vis[i]){
            ans = 'a'+i;
            break;
        }
    }
    for(int i = 0;i<k;i++){
        cout << ans;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int vis[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    //IOS
    ms(vis, 0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0;i<n;i++){
        vis[s[i]-'a'] = 1;
    }
    int Min = inf, Max = -1;
    for(int i = 0;i<26;i++){
        if(vis[i]){
            Min = min(Min, i);
            Max = max(Max, i);
        }
    }
    if(k<n){
    int pos;
    for(int i = k-1;i>=0;i--){
        if(s[i]-'a'<Max){
            pos = i;
            break;
        }
    }
    for(int i = 0;i<pos;i++){
        printf("%c", 'a'+Min);
    }printf("%c", 'a'+Max);
    for(int i = pos+1;i<k;i++){
        printf("%c", 'a'+Min);
    }
    }else{
        cout << s;
        for(int i = 0;i<k-n;i++){
            printf("%c", 'a'+Min);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int a[maxn];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0;i<k;i++){
        cout << 'z';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int vis[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    //IOS
    ms(vis, 0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0; i<n; i++) {
        vis[s[i]-'a'] = 1;
    }
    int Min;
    for(int i = 0;i<26;i++){
        if(vis[i]){
            Min = i;
            break;
        }
    }
    if(k<=n){
    int pos, ans;
    for(int i = min(k-1, n-1); i>=0; i--) {
        for(int j = s[i]-'a'+1;j<26;j++){
            if(vis[j]){
                pos = i;
                ans = j;
                goto hh;
            }
        }
    }
hh:
    for(int i = 0; i<pos; i++) {
        printf("%c", s[i]);
    }
    printf("%c", 'a'+ans);
//    printf("!");
    for(int i = pos+1; i<k; i++) {
        printf("%c", 'a'+Min);
    }

//    printf("!");
    }else{
        cout << s;
        for(int i = 0;i<k-n;i++){
            printf("%c", 'a' + Min);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 200 + 10;
const int mod = 1000000007;
int vis[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    //IOS
    ms(vis, 0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0; i<n; i++) {
        vis[s[i]-'a'] = 1;
    }
    int Min;
    for(int i = 0;i<26;i++){
        if(vis[i]){
            Min = i;
            break;
        }
    }
    int pos, ans;
    for(int i = min(k-1, n-1); i>=0; i--) {
        for(int j = s[i]-'a';j<26;j++){
            if(vis[j]){
                pos = i;
                ans = j;
                goto hh;
            }
        }
    }
hh:
    for(int i = 0; i<pos; i++) {
        printf("%c", s[i]);
    }
    printf("%c", 'a'+ans);
//    printf("!");
    for(int i = pos+1; i<k; i++) {
        printf("%c", 'a'+Min);
    }
//    printf("!");
    return 0;
}