import java.util.Scanner;

/**
 * Created by rkarumuru on 5/9/20
 **/
public class KthNotDivByN {

  private static Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {

    int t = getInt();
    for (int i = 0; i < t; i++) {
      solve();
    }

  }

  private static void solve() {
    long n = scanner.nextInt();
    long k = getInt();

    long l = k;
    long h = 2 * k;

    while (true) {
      long x = (l + h)/2;

      if (x == k + x/n) {
        System.out.println(x);
        break;
      } else if ((x > k + x/n)){
        h = x -1;
      } else {
        l = x + 1;
      }

    }
  }

  public static int getInt() {
    return Integer.parseInt(scanner.nextLine().trim());
  }

  public static String getString() {
    return scanner.nextLine().trim();
  }

  public static double getDouble() {
    return Double.parseDouble(scanner.nextLine());
  }

  public static long getlong() {
    return Long.parseLong(scanner.nextLine());
  }
}


import java.util.Scanner;

public class B {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while (t-- != 0) {

			int n = scn.nextInt();
			int k = scn.nextInt();
			int orig_k = k;
			if (k % (n - 1) == 0) {
				k -= 0.1;
			}
			int left_boundary_number = n * (int) Math.floor(k / (n - 1));
			int right_boundary_number = n * ((int) Math.floor(k / (n - 1)) + 1);
			int counter = ((n - 1) * (int) Math.floor(k / (n - 1)) + 1);
			for (int i = left_boundary_number + 1; i < right_boundary_number; i++) {
				if (counter == orig_k) {
					System.out.println(i);
					break;
				}
				counter++;
			}
		}

	}

}


package CF_Div4_May;

import java.util.ArrayList;
import java.util.Scanner;

public class B {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while (t-- != 0) {

			int n = scn.nextInt();
			int k = scn.nextInt();
			int orig_k = k;
			if (k % (n - 1) == 0) {
				k -= 0.1;
			}
			int left_boundary_number = n * (int) Math.floor(k / (n - 1));
			int right_boundary_number = n * ((int) Math.floor(k / (n - 1)) + 1);
			int counter = ((n - 1) * (int) Math.floor(k / (n - 1)) + 1);
			for (int i = left_boundary_number + 1; i < right_boundary_number; i++) {
				if (counter == orig_k) {
					System.out.println(i);
					break;
				}
				counter++;
			}
		}

	}

}


import java.util.Scanner;

public class B {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while (t-- != 0) {

			int n = scn.nextInt();
			int k = scn.nextInt();
			int orig_k = k;
			if (k % (n - 1) == 0) {
				k -= 0.1;
			}
			int left_boundary_number = n * (int) Math.floor(k / (n - 1));
			int right_boundary_number = n * ((int) Math.floor(k / (n - 1)) + 1);
			int counter = (n - 1) * (int) Math.floor(k / (n - 1));
			System.out.println(left_boundary_number + (orig_k - counter));
//			for (int i = left_boundary_number + 1; i < right_boundary_number; i++) {
//				if (counter == orig_k) {
//					System.out.println(i);
//					break;
//				}
//				counter++;
//			}
		}

	}

}


import java.util.*;
public class Solution
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        int test=scan.nextInt();
        while(test-->0)
        {
            int n=scan.nextInt();
            int k=scan.nextInt();
            long low=1,high=(int)1e18;
            int ans=0;
            while(low<=high)
            {
                long mid=(low+high)/2;
                if(mid-(mid/n)==k)
                {
                    ans=mid;
                    break;
                }
                else if(mid-(mid/n)>k)
                    high=mid-1;
                else
                    low=mid+1;
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;
public class Solution
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        int test=scan.nextInt();
        while(test-->0)
        {
            int n=scan.nextInt();
            int k=scan.nextInt();
            long low=1,high=(int)1e18;
            long ans=0;
            while(low<=high)
            {
                long mid=(low+high)/2;
                if(mid-(mid/n)==k)
                {
                    ans=mid;
                    high=mid-1;
                }
                else if(mid-(mid/n)>k)
                    high=mid-1;
                else
                    low=mid+1;
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;
public class Solution
{
    public static void main(String ar[])
    {
        int test=scan.nextInt();
        while(test-->0)
        {
            int n=scan.nextInt();
            int k=scan.nextInt();
            int low=1,high=(int)1e9;
            int ans=0;
            while(low<=high)
            {
                int mid=(low+high)/2;
                if(mid-(mid/n)==k)
                {
                    ans=mid;
                    break;
                }
                else if(mid-(mid/n)>k)
                    high=mid-1;
                else
                    low=mid+1;
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;
public class Solution
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        int test=scan.nextInt();
        while(test-->0)
        {
            int n=scan.nextInt();
            int k=scan.nextInt();
            long low=1,high=(int)1e18;
            long ans=0;
            while(low<=high)
            {
                long mid=(low+high)/2;
                if(mid-(mid/n)==k)
                {
                    ans=mid;
                    break;
                }
                else if(mid-(mid/n)>k)
                    high=mid-1;
                else
                    low=mid+1;
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;
public class Solution
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        int test=scan.nextInt();
        while(test-->0)
        {
            int n=scan.nextInt();
            int k=scan.nextInt();
            int low=1,high=(int)1e9;
            int ans=0;
            while(low<=high)
            {
                int mid=(low+high)/2;
                if(mid-(mid/n)==k)
                {
                    ans=mid;
                    break;
                }
                else if(mid-(mid/n)>k)
                    high=mid-1;
                else
                    low=mid+1;
            }
            System.out.println(ans);
        }
    }
}


import java.util.*;

public class newFile {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            int n = sc.nextInt();   int k = sc.nextInt();
            long x = n * (long) Math.floor(k/(n-1));
            if (k % (n-1) == 0) {
                x -= 1;
            }
            else {
                x += 1;
            }
            System.out.println(x);
        }
    }
}


import java.util.*;

public class newFile {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            long n = sc.nextInt();   long k = sc.nextInt();
            if (k < n) {
                System.out.println(k);
            }
            else {
                long x = n * (long) Math.floor(k/(n-1));
                if (k % (n-1) == 0) {
                    x -=  1;
                }
                else {
                    x += k % (n-1);
                }
                System.out.println(x);
            }
        }
    }
}


import java.util.*;

public class newFile {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            int n = sc.nextInt();   int k = sc.nextInt();
            if (k < n) {
                System.out.println(k);
            }
            else {
                long x = n * (long) Math.floor(k/(n-1));
                if (k % (n-1) == 0) {
                    x -= 1;
                }
                else {
                    x += 1;
                }
                System.out.println(x);
            }
        }
    }
}


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

public class C {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        int t=in.nextInt();
        while (t-->0){
            int n=in.nextInt();
            int k=in.nextInt();
            if(n>k){
                out.println(k);
                continue;
            }
            int res= (int) Math.floor(k*1.0/(n-1));
            long cur=res*n;
            long num=res*(n-1);
            if(k%n!=0)
                out.println((k-num)+cur);
            else out.println((k-num)+cur-1);
        }
        out.flush();
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}


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

public class C {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        int t=in.nextInt();
        while (t-->0){
            int n=in.nextInt();
            int k=in.nextInt();
            if(n>k){
                out.println(k);
                continue;
            }
            int res= (int) Math.floor(k*1.0/(n-1));
            long cur=res*n;
            long i;
            long num=res*(n-1);
            for(i=cur;num<k;i++){
                if(i%n!=0){
                    num++;
                }
            }
            out.println(i-1);
        }
        out.flush();
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}


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

public class C {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        int t=in.nextInt();
        while (t-->0){
            int n=in.nextInt();
            int k=in.nextInt();
            if(n>k){
                out.println(k);
                continue;
            }
            int res= (int) Math.floor(k*1.0/(n-1));
            long cur=res*n;
            long num=res*(n-1);
            if(k%(n-1)!=0)
                out.println((k-num)+cur);
            else out.println((k-num)+cur-1);
        }
        out.flush();
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}


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

public class C {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        InputReader in=new InputReader(System.in);
        int t=in.nextInt();
        while (t-->0){
            int n=in.nextInt();
            int k=in.nextInt();
            int res= (int) Math.floor(k*1.0/(n-1));
            long cur=res*n;
            long i;
            long num=res*(n-1);
            for(i=cur;num<k;i++){
                if(i%n!=0){
                    num++;
                }
            }
            out.println(i-1);
        }
        out.flush();
    }
    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            tokenizer = null;
        }
        public String next() throws IOException{
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
}


import java.util.Scanner;

public class KthNotDivisibleByN {

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

        while (t-- > 0) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();

            if (n > k) System.out.println(k);
            else if (n <= k) {
                if ((k / n) != 0) {
                    int sum = k + (k / n);
                    int values = sum - (sum / n);
                    while (values < k) {

                        sum += (k - values);
                        values = sum - (sum / n);
                    }
                    System.out.println(sum);
                }
            }
        }

    }
}


import java.util.Scanner;

public class KthNotDivisibleByN {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t=scanner.nextInt();
        while (t-->0){
            int n = scanner.nextInt();
            int k = scanner.nextInt();

            if (n > k) System.out.println(k);
            else if (n <= k) {

                if ((k / n) != 0) {
                    int sum = k + (k / n);
                    int remainder = sum - (sum / n);
                    int value = sum;
                    while (remainder < k) {
                        value++;
                        if (value % n != 0) {
                            remainder++;
                        }

                    }

                    System.out.println(value);
                }

            }

        }

    }
}


import java.util.Scanner;

public class KthNotDivisibleByN {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        if (n > k) System.out.println(k);
        else if (n <= k) {

            if ((k / n) != 0) {
                int sum = k + (k / n);
                int remainder = sum - (sum / n);
                int value = sum;
                while (remainder < k) {
                    value++;
                    if (value % n != 0) {
                        remainder++;
                    }

                }

                System.out.println(value);
            }

        }

    }
}


import java.util.Scanner;

public class KthNotDivisibleByN {

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

        while (t-- > 0) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();

            if (n > k) System.out.println(k);
            else if (n <= k) {
                    int sum = k + (k / n);
                    int values = sum - (sum / n);
                    while (values < k) {
                        sum += (k - values);
                        values = sum - (sum / n);
                    }
                    System.out.println(sum);
            }
        }
    }
}


// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{

    public static void main(String[] args)
	{
		FastReader sc=new FastReader();
		int test=sc.nextInt();
		while(test-->0)
		{
           double n=sc.nextDouble();
           double k=sc.nextDouble();
           double div=k/(n-1);
           double ans=div*n;
           if(ans == (long)ans)
           System.out.println((long)(ans-1));
           else
           System.out.println((long)ans);

		}

	}

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

}


//189301019.akshay
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Collections;

public class A
{
    public static void main(String[] args)
	{
		FastReader sc=new FastReader();
		StringBuffer ans=new StringBuffer();
		int test=sc.nextInt();
		while(test-->0)
		{
//			int n=sc.nextInt();
			long n=sc.nextLong(),k=sc.nextLong();
			long division = k/(n-1);//16
			long cur=0;
			if(division == 0) {
				cur=(k);
			}
			else {
				 cur=0;
				cur = division*n;//16*7
				long num=cur;
				cur-=(division);//-16
				if(cur<k) {
					num+=(k-cur);
				}
				if(cur == k)
				{
					--num;
				}
				cur=num;
			}
			ans.append(cur+"\n");

		}

	    System.out.print(ans);
	}

    static final Random random=new Random();

	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}

	static void ruffleSort(long[] a) {
		int n=a.length;//shuffle, then sort
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n);
			long temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}

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

}


import java.util.*;
import java.io.*;
public class KthNotDivisibleByN {
	static FS sc = new FS();
	static PrintWriter pw = new PrintWriter(System.out);

	static long n, k;
	public static void main(String[] args) {
		int t = sc.nextInt();
		for(int tt = 1; tt <= t; ++tt) {
			n = sc.nextLong();
			k = sc.nextLong();

			// algebra
			long ans = n * k / (n - 1);
			if((ans - 1) - (ans - 1) / n == k) --ans;

			pw.println(ans);
		}
		pw.flush();
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
public class KthNotDivisibleByN {
	static FS sc = new FS();
	static PrintWriter pw = new PrintWriter(System.out);

	static long n, k;
	public static void main(String[] args) {
		int t = sc.nextInt();
		for(int tt = 1; tt <= t; ++tt) {
			n = sc.nextLong();
			k = sc.nextLong();

			// algebra
			long ans = n * k / (n - 1);
			if(ans % n == 0) --ans;

			pw.println(ans);
		}
		pw.flush();
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
public class c {
	static final FS sc = new FS();
	static final PrintWriter pw = new PrintWriter(System.out);

	static final long max = 1_000_000_000;
	public static void main(String[] args) {
		int t = sc.nextInt();
		for(int tt = 1; tt <= t; ++tt) {
			long n = sc.nextInt(), k = sc.nextInt();

			long lo = 1, hi = max * 2;
			while(lo < hi) {
				long g = (lo + hi) / 2;

				// find number of numbers below not divisible by n
				long num = g - (g / n);

				if(num < k) lo = g + 1;
				else if(num > k) hi = g - 1;
				else hi = g;
			}

			pw.println(lo);
		}
		pw.flush();
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

public class Testclass
{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            System.out.println(s*d+r);

        }

    }

}


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

public class Testclass{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            for(int i=0;i<=Integer.parseInt(tok[0])*Integer.parseInt(tok[1]);i++)
            {
                if(i%Integer.parseInt(tok[0])!=0)
                {
                    count++;
                }
                if(count==Integer.parseInt(tok[1]))
                {
                    System.out.println(i);
                }

            }

        }

    }

}


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

public class Abh

{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            if(d==h||r!=0)
            {
            System.out.println(s*d+r);
            }
            else
            {
                System.out.println(s*d+r-1);
            }

        }

    }

}


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

public class Testclass
{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            if(d%2!=0)
          {
            System.out.println(s*d+r);
          }
         else
         {
            System.out.println(s*d+r-1);
         }

        }

    }

}


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

public class Abh

{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            if(d%2!=0)
            {
            System.out.println(s*d+r);
            }
            else
            {
                System.out.println(s*d+r-1);
            }

        }

    }

}


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

public class Abh

{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            if((d-1)*d==h)
            {
            System.out.println(s*d+r-1);
            }
            else
            {
                System.out.println(s*d+r);
            }

        }

    }

}


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

public class Abh

{

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        int count=0;
        while(t-->0)
        {
            String[] tok=br.readLine().split(" ");
            long d=Long.parseLong(tok[0]);
            long h=Long.parseLong(tok[1]);
            long s=h/(d-1);
            long r=h%(d-1);
            if(r!=0)
            {

            System.out.println(s*d+r);
            }
            else if(d==h)

            {
                System.out.println(d+1);
            }
            else
            {
                System.out.println(s*d+r-1);
            }

        }

    }

}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

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

/**
 *
 * @author ujjwal abhishek
 */
public class ProblemC
{
  static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
    public static void main(String []args)throws IOException
    {
       Reader sc=new Reader();
       int t=sc.nextInt();
       while (t-->0)
       {
           int n=sc.nextInt();
           int k=sc.nextInt();
           int x=(int) Math.floor((k-1)/(float)(n-1));
           System.out.println(x+k);
       }
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

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

/**
 *
 * @author ujjwal abhishek
 */
public class ProblemC
{
  static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
    public static void main(String []args)throws IOException
    {
       Reader sc=new Reader();
       int t=sc.nextInt();
       while (t-->0)
       {
           int n=sc.nextInt();
           int k=sc.nextInt();
           int x=k/(n-1);
           int r=k%(n-1);
           if (r==0)
               System.out.println(n*x-1);
           else
               System.out.println(n*x+r);
       }
    }
}


//package solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Main().run();
                } catch(Exception | Error ex) {ex.printStackTrace();}
            }
        }, "solution", 1<<26).start();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        int t = ni();
        for(int I=1; I<=t; I++) {
            long n = ni(), k = ni();
            pl(find(n, k));
        }
    }

    long find(long n, long k) {
        long low = 1, high = 10000000000L, mid;
        while(high - low > 4) {
            mid = (high + low) >> 1;
            if(pos(mid, n) == k) {
                return mid;
            } else {
                if(pos(mid, n) < k) {
                    low  = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
        }
        for(long i=low; i<=high; i++) {
            if(pos(i, n) == k) return i;
        }
        return -1;
    }

    long pos(long idx, long n) {
        return idx - (idx / n);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

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

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

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

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


//package solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Main().run();
                } catch(Exception | Error ex) {ex.printStackTrace();}
            }
        }, "solution", 1<<26).start();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        int t = ni();
        for(int I=1; I<=t; I++) {
            long n = ni(), k = ni();
            pl(find(n, k));
        }
    }

    long find(long n, long k) {
        long low = 1, high = 10000000000L, mid;
        while(high - low > 1) {
            mid = (high + low) >> 1;
            if(pos(mid, n) == k) {
                if(pos(mid-1, n) == k) return mid-1;
                return mid;
            } else {
                if(pos(mid, n) < k) {
                    low  = mid;
                } else {
                    high = mid;
                }
            }
        }
        for(long i=low; i<=high; i++) {
            if(i % n == 0) continue;
            if(pos(i, n) == k) return i;
        }
        return -1;
    }

    long pos(long idx, long n) {
        return idx - (idx / n);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

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

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

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

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


//package solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Main().run();
                } catch(Exception | Error ex) {ex.printStackTrace();}
            }
        }, "solution", 1<<26).start();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        int t = ni();
        for(int I=1; I<=t; I++) {
            long n = ni(), k = ni();
            pl(find(n, k));
        }
    }

    long find(long n, long k) {
        long low = 1, high = 10000000000L, mid;
        while(high - low > 10) {
            mid = (high + low) >> 1;
            if(pos(mid, n) == k) {
                return mid;
            } else {
                if(pos(mid, n) < k) {
                    low  = mid;
                } else {
                    high = mid;
                }
            }
        }
        for(long i=low; i<=high; i++) {
            if(pos(i, n) == k) return i;
        }
        return -1;
    }

    long pos(long idx, long n) {
        return idx - (idx / n);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

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

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

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

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


//package solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Main().run();
                } catch(Exception | Error ex) {ex.printStackTrace();}
            }
        }, "solution", 1<<26).start();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        int t = ni();
        for(int I=1; I<=t; I++) {
            long n = ni(), k = ni();
            pl(find(n, k));
        }
    }

    long find(long n, long k) {
        long low = 1, high = 10000000000L, mid;
        while(high - low > 100) {
            mid = (high + low) >> 1;
            if(pos(mid, n) == k) {
                return mid;
            } else {
                if(pos(mid, n) < k) {
                    low  = mid;
                } else {
                    high = mid;
                }
            }
        }
        for(long i=low; i<=high; i++) {
            if(pos(i, n) == k) return i;
        }
        return -1;
    }

    long pos(long idx, long n) {
        return idx - (idx / n);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

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

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

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

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-- > 0){
            int n = s.nextInt();
            int k = s.nextInt();
            int ans = -1;

            int temp = n - 1, curnum = n - 1, ptr = 2;
            while(temp < k){
                temp += (n-1);

            }

            System.out.println(((temp/(n-1)) * n) - 1 - (temp - k)  );

		}
	}
}
// 10
// 15
// 1999999999
// 113
// 1000000001
// 1


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-- > 0){
            int n = s.nextInt();
            int k = s.nextInt();

            if(k < n){
                System.out.println(k);
                continue;
            }

            int c = k / (n-1);
            int ans = c * n + (k % (n-1) == 0 ? -1: k % (n-1));

            System.out.println(ans);

		}
	}
}
// 10
// 15
// 1999999999
// 113
// 1000000001
// 1


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-- > 0){
            int n = s.nextInt();
            int k = s.nextInt();

            int temp = n - 1, curnum = n - 1;
            int ptr = n/k;
            while(temp < k){
                temp = (n * ptr) - ptr;
                curnum = (n * ptr) - 1;
                ptr++;
            }

            while(temp > k){
                curnum--;
                temp--;
            }

            System.out.println(curnum);

		}
	}
}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-- > 0){
            int n = s.nextInt();
            int k = s.nextInt();

            int temp = n - 1, curnum = n - 1;
            int ptr = 2;
            while(temp < k){
                temp = (n * ptr) - ptr;
                curnum = (n * ptr) - 1;
                ptr++;
            }

            while(temp > k){
                curnum--;
                temp--;
            }

            System.out.println(curnum);

		}
	}
}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t-- > 0){
            int n = s.nextInt();
            int k = s.nextInt();
            int ans = -1;

            if(k < n){
                System.out.println(k);
                continue;
            }else if(k == n){
                System.out.println(k + 1);
                continue;
            }

            int temp = n - 1, curnum = n - 1, ptr = 2;
            while(temp < k){
                temp += (n-1);

            }

            System.out.println(((temp/(n-1)) * n) - 1 - (temp - k)  );

		}
	}
}
// 10
// 15
// 1999999999
// 113
// 1000000001
// 1


import java.util.*;
public class test
{
   public static void main(String args[])
   {
       Scanner sc=new Scanner(System.in);
       int t=sc.nextInt();
       for(int co=0;co<t;co++)
       {
           long n=sc.nextLong();
           long k=sc.nextLong();
           if(n==2)
            System.out.println(2*k-1);
           else
           {
           long g=k,ans=k;
           while(g/n!=0)
           {
              ans+=(long)g/n;
              long f=(long)Math.floor(g/n);
              long ne=n*(f+1);
              if(ne-g<=g/n)
               ans++;
              g=(long)g/n;
              if(g==n)
               break;
           }
           System.out.println(ans);
           }
       }
   }
}


import java.util.*;
public class test
{
   public static void main(String args[])
   {
       Scanner sc=new Scanner(System.in);
       int t=sc.nextInt();
       for(int co=0;co<t;co++)
       {
           long n=sc.nextLong();
           long k=sc.nextLong();
           if(n==2)
            System.out.println(2*k-1);
           else
           {
           long g=k,ans=k;
           while(g/n!=0)
           {
              ans+=(long)g/n;
              long f=(long)Math.floor(g/n);
              long ne=n*(f+1);
              if(ne-g<=g/n)
               ans++;
              g=(long)g/n;
           }
           System.out.println(ans);
           }
       }
   }
}


n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=1
high=sum(a[:k])
tmp=high
x=0
for i in range(k,n-k+1):
    tmp=tmp+(a[i]-a[x])
    if tmp<high:
        high=tmp
    x+=1
print(x+1)


n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=1
high=sum(a[:k])
for i in range(1,n-k+1):
    tmp=sum(a[i:i+k])
    if tmp<high:
        high=tmp
        ans=i+1
print(ans)


n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=1
high=sum(a[:k])
tmp=high
x=0
if k==1:
    ans=min(a)
    print(a.index(ans)+1)
else:
    for i in range(k,n-k+1):
        tmp=tmp+(a[i]-a[x])
        if tmp<high:
            high=tmp
        x+=1
    print(x+1)


n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
high=a[k-1]
ans=1
for i in range(1,n-k+1):
    s=a[i+k-1]-a[i-1]
    if s<high:
        ans=i+1
        high=s
print(ans)


n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=1
high=sum(a[:k])
tmp=high
x=0
if k==1:
    ans=min(a)
    print(a.index(ans)+1)
else:
    for i in range(k,n-k+1):
        tmp=tmp+(a[i]-a[x])
        if tmp<high:
            high=tmp
            ans=x+1
        x+=1
    print(ans)


n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
high=a[k]
ans=1
for i in range(1,n-k+1):
    s=a[i+k-1]-a[i-1]
    if s<high:
        ans=i+1
        high=s
print(ans)


from itertools import accumulate
n, k = map(int,input().split())
arr = list(map(int,input().split()))

prefix = list(accumulate(arr))

#print(prefix)

mn = prefix[k - 1]
indx = 0
for i in range(1 , n):
    x = i + k
    if x <= n :
        x2 = prefix[x - 1] - prefix[i - 1]
        if x2 < mn :
            mn = x2
            indx = i

    else:
        continue

#print(mn)
print(indx + 1)


from itertools import accumulate
n, k = map(int,input().split())
arr = list(map(int,input().split()))

prefix = list(accumulate(arr))

#print(prefix)

mn = prefix[k - 1]
indx = 0
for i in range(1 , n):
    x = i + k
    if x < n :
        x2 = prefix[x - 1] - prefix[i - 1]
        if x2 < mn :
            mn = x2
            indx = i

    else:
        continue

#print(mn)
print(indx + 1)


from sys import *
for _ in range(1):
    n,k=map(int,stdin.readline().split())
    l=list(map(int,stdin.readline().split()))
    a=1
    m=t=sum(l[:k])
    for i in range(k,n):
        t+=l[i]-l[i-k]
        if t<m:
            a=i-k+2;
            m=t
        #print(a,m)
    print(a)


from sys import *
for _ in range(1):
    n,k=map(int,stdin.readline().split())
    l=list(map(int,stdin.readline().split()))
    if(k==1):
       print(l.index(min(l))+1)
       continue
    s=sum(l[:k])
    c=10**8+9
    j=0
    for i in range(1,n-k+1):
        s+=l[i+k-1]-l[i-1]
        if c>s:
            c=s
            j+=1
    print(j+1)


from sys import *
for _ in range(1):
    n,k=map(int,stdin.readline().split())
    l=list(map(int,stdin.readline().split()))
    s=sum(l[:k])
    c=10**8+9
    j=0
    for i in range(1,n-k+1):
        s+=l[i+k-1]-l[i-1]
        if c>s:
            c=s
            j+=1
    print(j+1)


from sys import *
for _ in range(1):
    n,k=map(int,stdin.readline().split())
    l=list(map(int,stdin.readline().split()))
    if(k==1):
       print(l.index(min(l)))
       continue
    s=sum(l[:k])
    c=10**8+9
    j=0
    for i in range(1,n-k+1):
        s+=l[i+k-1]-l[i-1]
        if c>s:
            c=s
            j+=1
    print(j+1)


from sys import *
for _ in range(1):
    n,k=map(int,stdin.readline().split())
    l=list(map(int,stdin.readline().split()))
    if(k==1)
    {
       print(l.index(min(l)))
       continue
    }
    s=sum(l[:k])
    c=10**8+9
    j=0
    for i in range(1,n-k+1):
        s+=l[i+k-1]-l[i-1]
        if c>s:
            c=s
            j+=1
    print(j+1)


n,k=map(int,input().split())
l=list(map(int,input().split()))
d=[l[0]]
s=l[0]
for i in range(1,n):
    s=s+l[i]
    d.append(s)
m=d[k-1]
j=0
for i in range(k,n):
    x=d[i]-d[i-k]
    if(m>x):
        m=x
        j=i-k+2
print(j)


n,k=map(int,input().split())
l=list(map(int,input().split()))
d=[l[0]]
s=l[0]
for i in range(1,n):
    s=s+l[i]
    d.append(s)
m=d[k-1]
j=1
for i in range(k,n):
    x=d[i]-d[i-k]
    if(m>x):
        m=x
        j=i-k+2
print(j)


n , k = map(int , input().split())
a = list(map(int , input().split()))
s = 0
x = 0
for i in range(k):
    s+=a[i]

for i in range(1,(n-k+1)):

    if s>(a[i]+a[i+1]+a[i+2]):
        s = a[i]+a[i+1]+a[i+2]
        x = i

print(x+1)


n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
t=s=sum(a[:k])
an=1
for i in range(k,n):
    t+=a[i]-a[i-k]
    if t<s: s=t; an=i-k+2
print(an)


n , k = map(int , input().split())
a = list(map(int , input().split()))
s = 0
x = 0
for i in range(k):
    s+=a[i]

for i in range(1,n-k):
    if s>(a[i]+a[i+1]+a[i+2]):
        s = a[i]+a[i+1]+a[i+2]
        x = i

print(x+1)


n , k = map(int , input().split())
a = list(map(int , input().split()))
s = 0
x = 0
for i in range(k):
    s+=a[i]
if k==1:
    x = a.index(min(a))
elif k!=n-1 or k!=n:
    for i in range(1,(n-k+1)):

        if s>(a[i]+a[i+1]+a[i+2]):
            s = a[i]+a[i+1]+a[i+2]
            x = i

print(x+1)


# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:14:41 2019

@author: Mridul Garg
"""

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

b = [0]*(n+1)
count = 0
for i in range(n):
    count += a[i]
    b[i+ 1] = count

ans = [0]*(n-k)
for i in range(1, n-k+1):
    ans[i - 1] = b[i + k - 1] - b[i - 1]

index = ans.index(min(ans))
print(index + 1)


# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:14:41 2019

@author: Mridul Garg
"""

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

if n == k:
    print(sum(a))

else:

    b = [0]*(n+1)
    count = 0
    for i in range(n):
        count += a[i]
        b[i+ 1] = count

    ans = [0]*(n-k)
    for i in range(1, n-k+1):
        ans[i - 1] = b[i + k - 1] - b[i - 1]

    index = ans.index(min(ans))
    print(index + 1)


# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:14:41 2019

@author: Mridul Garg
"""

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

if n == k:
    print(1)

else:

    b = [0]*(n+1)
    count = 0
    for i in range(n):
        count += a[i]
        b[i+ 1] = count

    ans = [0]*(n-k)
    for i in range(1, n-k+1):
        ans[i - 1] = b[i + k - 1] - b[i - 1]

    index = ans.index(min(ans))
    print(index + 1)


# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 14:14:41 2019

@author: Mridul Garg
"""

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

if n == k:
    print(1)

else:

    b = [0]*(n+1)
    count = 0
    for i in range(n):
        count += a[i]
        b[i+ 1] = count

#    print(b)
#    print()

    ans = [0]*(n-k + 1)
    for i in range(1, n-k+ 2):
        ans[i - 1] = b[i + k - 1] - b[i - 1]
#        print(ans)

    index = ans.index(min(ans))
    print(index + 1)


n,k=map(int,input().split())
l=[int(j) for j in input().split()]
s=0
m=10**8
t=0
for i in range(n):
    s+=l[i]
    if i>=k:
        s-=l[i-k]
        if s<m:
            m=s
            t=i-k+1
print(t+1)


n,k=map(int,input().split())
l=[int(j) for j in input().split()]
s=0
m=10**8
t=0
for i in range(n):
    s+=l[i]
    if i+1>k:
        s-=l[i-k]
    if s<m:
            m=s
            t=i-k+1
print(t+1)


n,k=map(int,input().split())
l=[int(j) for j in input().split()]
s=0
m=10**8
t=0
for i in range(n):
    s+=l[i]
    if i+1>k:
        s-=l[i-k]
    if i+1>=k:
        if s<m:
            m=s
            t=i-k+1

print(t+1)


n,k = map(int,input().split())
if n==1:
    print(1)
else:

    a=[int(x) for x in input().split()]
    s=0
    for i in range(k):
        s+=a[i]
    i=0
    an=0
    z= s
    for j in range(k,n):
        s-=a[i]
        s+=a[j]
        if s<z:
            an = i+1
            z=s
        i+=1
    print(an+1)


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

s=0

for i in range(k):
    s+=a[i]

i=0
z= s
for j in range(k,n):
    s-=a[i]
    s+=a[j]
    if s<z:
        an = i+1
    i+=1
print(an+1)


n,k = map(int,input().split())
if n==1:
    print(1)
else:

    a=[int(x) for x in input().split()]
    s=0
    for i in range(k):
        s+=a[i]
    i=0
    an=0
    z= s
    for j in range(k,n):
        s-=a[i]
        s+=a[j]
        if s<z:
            an = i+1
        i+=1
    print(an+1)


n,k=map(int,input().split())
l=list(map(int,input().split()))
x=j=sum(l[:k])
ans=1
for i in range(k,n):
    j=j-l[i-k]+l[i]
    if(j<x):
        x=j
        ans=i-1
print(ans)


n,k=map(int,input().split())
l=list(map(int,input().split()))
x=j=sum(l[:k])
ans=1
for i in range(k,n):
    j=j-l[i-k]+l[i]
    if(j<x):
        x=j
        ans=i-k+2
print(ans)


n,k=map(int,input().split())
l=list(map(int,input().split()))
x=j=sum(l[:k])
ans=0
for i in range(k,n):
    j=j-l[i-k]+l[i]
    if(j<x):
        x=j
        ans=i-1
print(ans)


n, k = [int(x) for x in input().split(' ')]
h = [int(x) for x in input().split(' ')]
s = sum(h[:k])
m = s
index = 0
for i in range(n - k - 1):
    s -= h[i]
    s += h[i + k]
    if s < m:
        m = s
        index = i
print(index + 2)


n, k = [int(x) for x in input().split(' ')]
h = [int(x) for x in input().split(' ')]
s = sum(h[:k])
m = s
index = - 1
for i in range(n - k - 1):
    s -= h[i]
    s += h[i + k]
    if s < m:
        m = s
        index = i
print(index + 2)


n, k = [int(x) for x in input().split(' ')]
h = [int(x) for x in input().split(' ')]
s = sum(h[:k])
m = s
for i in range(n - k):
    s -= h[i]
    s += h[i + k]
    m = min(m, s)
print(m)


n, k = [int(x) for x in input().split(' ')]
h = [int(x) for x in input().split(' ')]
s = sum(h[:k])
m = s
index = - 1
for i in range(n - k):
    s -= h[i]
    s += h[i + k]
    if s < m:
        m = s
        index = i
print(index + 2)


def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    init_sum = 0
    index = 0

    for i in range(k):
        init_sum += a[i]

    i = k
    curr_sum = init_sum
    while i < n:
        curr_sum += a[i] - a[i-k]
        if curr_sum < init_sum:
            init_sum = curr_sum
            index = i-k+1
        i += 1
    print(index+1)
if __name__ == '__main__':
    main()


def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    init_sum = 0
    index = 0

    for i in range(k):
        init_sum += a[i]

    i = k
    while i < n:
        if init_sum + a[i] - a[i-k] < init_sum:
            index = i-k+1
        i += 1
    print(index+1)
if __name__ == '__main__':
    main()


def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    init_sum = 0
    index = 0

    for i in range(k):
        init_sum += a[i]

    i = k
    while i < n:
        if init_sum + a[i] - a[i-k] < init_sum:
            init_sum += a[i]-a[i-k]
            index = i-k+1
        i += 1
    print(index+1)
if __name__ == '__main__':
    main()


n,k=map(int, input().split())
a=list(map(int, input().split()))
s=sum(a[:k])
ans=[0]*(n-k+1)
for i in range(0,n-k+1):
    ans[i]=sum(a[i:i+k])
    s=min(sum(a[i:i+k]),s)
print(ans.index(s)+1)


n,k=map(int, input().split())
a=list(map(int, input().split()))
s=sum(a[:k])
ans=[0]*(n-k+1)
ans[0]=s
for i in range(1,n-k+1):
    ans[i]=ans[i-1]-a[i-1]+a[i+k-1]
#print(ans)
print(ans.index(min(ans))+1)


n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==1:
    ind = a.index(min(a)) + 1
    print(ind)
elif n==k:
    print(1)
else:
    m=sum(a[:k])
    sumx=0
    ind=1
    for i in range(1,n-k+1):
        sumx=m+a[i+k-1]-a[i-1]
        if m>sumx:
            m=sumx
            ind=i+1
    print(ind)


n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==k:
    print(1)
else:
    m=sum(a[:k])
    sumx=0
    ind=1
    for i in range(1,n-k+1):
        sumx=m+a[i+k-1]-a[i-1]
        if m>sumx:
            m=sumx
            ind=i+1
    print(ind)


n,k=map(int,input().split())
a=list(map(int,input().split()))
if k==1:
    ind = a.index(min(a)) + 1
    print(ind)
elif n==k:
    print(1)
else:
    ans=[0]*(n-k+1)
    ans[0]=sum(a[:k])
    for i in range(1,len(ans)):
        ans[i]=ans[i-1]-a[i-1]+a[i+k-1]
    print(ans.index(min(ans)) + 1)


n,k=map(int,input().split())
a=list(map(int,input().split()))
m=1000000000000
for i in range(len(a)-k+1):
    if(sum(a[i:i+k])<m):
        m=sum(a[i:i+k])
        s=i+1
print(s)


n,k=map(int,input().split())
a=list(map(int,input().split()))
m=1000000000000
l=sum(a[:k])
if(n==k):
    print(1)
    exit()
for i in range(len(a)-k):
    if(l<m):
        m=l
        s=i+1
    l=(l-a[i]+a[k+i])
print(s)


n,k=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
m=1000000000000
l=sum(a[:k])
if(n==k):
    print(1)
    exit()
for i in range(len(a)-k):
    if(l<m):
        m=l
        s=i+1
    l=(l-a[i]+a[k+i])
print(s)


n,k=map(int,input().split())
a=list(map(int,input().split()))
m=1000000000000
l=sum(a[:k])
if(n==1):
    print(1)
    exit()
for i in range(len(a)-k):
    if(l<m):
        m=l
        s=i+1
    l=(l-a[i]+a[k+i])
print(s)


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

s=sum(arr[0:m])
index=0
if m==1:
    print(arr.index(min(arr))+1)
else:
    for i in range(m,n):
        a=s-arr[i-m]+arr[i]
        if a<s:
            s=a
            index=i-m+1
    print(index+1)


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

s=sum(arr[0:m])
index=0
if m==1:
    print(min(arr))
else:
    for i in range(m,n):
        a=s-arr[i-m]+arr[i]
        if a<s:
            s=a
            index=i-m+1
    print(index+1)


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

s=sum(arr[0:m])
index=0
for i in range(m,n):
    a=s-arr[i-m]+arr[i]
    if a<s:
        s=a
        index=i-m+1
print(index+1)


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

s=10**10
index=0
for i in range(n-m):
    a=sum(arr[i:i+m])
    if a<s:
        s=a
        index=i
print(index+1)


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

s=sum(arr[0:m])
minimum=s
index=0

for i in range(m, n):
    s = s - arr[i - m] + arr[i]
    if  s<minimum:
        minimum=s
        index = i - m + 1
print(index + 1)


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

s=sum(arr[0:m])
index=0
if m==1:
    print(arr.index(min(arr)))
else:
    for i in range(m,n):
        a=s-arr[i-m]+arr[i]
        if a<s:
            s=a
            index=i-m+1
    print(index+1)


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

s=sum(arr[0:m])
index=0
for i in range(n-m):
    a=s-arr[i-1]+arr[i+m-1]
    if a<s:
        s=a
        index=i
print(index+1)


n,m=map(int,input().strip().split())
arr=list(map(int,input().strip().split()))
print(arr)
s=10**10
index=0
for i in range(n-m):
    a=sum(arr[i:i+m])
    if a<s:
        s=a
        index=i
print(index+1)


m, k = list(map(int, input().split()))
lst = list(map(int, input().split()))

minn = float("inf")
ind = 0
val = sum(lst[:k])
p, n = -1, k-1
for i in range(m-k+1):
	if i != 0:
		val += lst[n] - lst[p]
	p += 1
	n += 1
	if minn > val:
		ind = i
		minn = val
print(ind+1)


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

minn = float("inf")
ind = 0
for i in range(n-k+1):
	val = sum(lst[i:i+k])
	if minn > val:
		ind = i
		minn = val
print(ind+1)


n,k=map(int,input().split())
l=list(map(int,input().split()))
summ=sum(l[:k])
maxx=9999999999999999
ind=1
for i in range(3,len(l)):
    summ-=l[i-k]
    summ+=l[i]
    if summ<maxx:
        maxx=summ
        ind=i-k+2
print(ind)


n,k=map(int,input().split())
l=list(map(int,input().split()))
summ=sum(l[:k])
maxx=9999999999999999
ind=1
if k==n:
    print(ind)
else:

    for i in range(3, len(l)):
        summ -= l[i - k]
        summ += l[i]
        if summ < maxx:
            maxx = summ
            ind = i - k + 2
    print(ind)


n,k=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l[:k])
m=s
ind=0
for i in range(1,n-k+1):
    s=s-l[i-1]+l[i+k-1]
    if m>s:
        m=s
        ind=i
print(ind+1)


n,k=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
w=sum(a[:k])
r=0
for i in range(k,n):
    r+=a[i]-a[i-k]
    if r<w:
        j=i-k+2
        w=r
print(j)


n,k=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
w=sum(a[:k])
j=1
r=sum(a[:k])
for i in range(k,n):
    w+=a[i]-a[i-k]
    if w<r:
        j=i-k+2
        r=w
print(j)


n,k=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
w=sum(a[:k])
j=0
r=0
for i in range(k,n):
    r+=a[i]-a[i-k]
    if r<w:
        j=i-k+2
        w=r
print(j)


n,k=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
w=[]
for i in range(n-k+1):
    w.append(sum(a[i:i+k]))
r=w.index(min(w))
print(r+1)


from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re  # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n  , k = tup()
ls  =lint()
mi = maxsize
a = sum(ls[:k])
idx = 0
for i in range(n-k):
    a = a - ls[i] + ls[i+ k]
    #mi = min(a , mi)
    if a < mi:
        mi = a
        idx  = i+k - 1
        #print(i)
print(idx)


from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re  # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n  , k = tup()
ls  =lint()
if n==1:
    print(1)
    exit()

a = sum(ls[:k]) ; idx = 1
mi  = a
for i in range(n - k):
    a = a - ls[i] + ls[i+k]
    if a < mi:
        a= mi
        idx = i+2
print(idx)


from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re  # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n  , k = tup()
ls  =lint()
if n==1:
    print(1)
    exit()
mi = maxsize
a = sum(ls[:k]) ; idx = 1
for i in range(n - k):
    a = a - ls[i] + ls[i+k]
    if a < mi:
        mi = a
        idx =  i + k - 1
print(idx)


from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re  # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n  , k = tup()
ls  =lint()
if n==1:
    print(1)
    exit()
mi = maxsize
a = sum(ls[:k])
idx = 0

for i in range(n-k):
    a = a - ls[i] + ls[i+ k]
    #mi = min(a , mi)
    if a < mi:
        mi = a
        idx  = i+1
        #print(i)
print(idx)


from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re  # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n  , k = tup()
ls  =lint()
if n==1:
    print(1)
    exit()
mi = maxsize
a = sum(ls[:k])
idx = 0

for i in range(n-k):
    a = a - ls[i] + ls[i+ k]
    #mi = min(a , mi)
    if a < mi:
        mi = a
        idx  = i+2
        #print(i)
print(idx)


n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 1e10
ans_n = 0
cur = sum(A[:k])
cur_n = 1
while cur_n + k - 1 < n:
    cur -= A[cur_n - 1]
    cur += A[cur_n + k - 1]
    if cur < ans:
        ans = cur
        ans_n = cur_n
    cur_n += 1
print(ans_n)


n, k = map(int, input().split())
A = list(map(int, input().split()))
ans_n = 1
cur = sum(A[:k])
ans = cur
cur_n = 1
while cur_n + k - 1 < n:
    cur -= A[cur_n - 1]
    cur += A[cur_n + k - 1]
    if cur < ans:
        ans = cur
        ans_n = cur_n
    cur_n += 1
print(ans_n + 1)


n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 1e10
ans_n = 0
cur = sum(A[:k])
cur_n = 1
while cur_n + k - 1 < n:
    cur -= A[cur_n - 1]
    cur += A[cur_n + k - 1]
    if cur < ans:
        ans = cur
        ans_n = cur_n
    cur_n += 1
print(ans_n + 1)


n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 1e10
ans_n = 0
cur = sum(A[:k])
cur_n = 1
while cur_n + k - 1 < n:
    print(cur_n, cur)
    cur -= A[cur_n - 1]
    cur += A[cur_n + k - 1]
    if cur < ans:
        ans = cur
        ans_n = cur_n
    cur_n += 1
print(ans_n + 1)


n, k = map(int, input().split())
A = list(map(int, input().split()))
ans_n = 0
cur = sum(A[:k])
ans = cur
cur_n = 1
while cur_n + k - 1 < n:
    cur -= A[cur_n - 1]
    cur += A[cur_n + k - 1]
    if cur < ans:
        ans = cur
        ans_n = cur_n
    cur_n += 1
print(ans_n + 1)


n, k = map(int, input().split())
arr = list(map(int, input().split()))
arrAns = []
indexArr = []
for i in range(n):
    if(i == 0):
        arrAns.append(arr[0])
    else:
        arrAns.append(arr[i]+arrAns[i-1])
for i in range(n-k+1):
    if(i==0):
        indexArr.append(arrAns[i+k-1])
    else:
        indexArr.append(arrAns[i+k-1] -arrAns[i-1])

if(not indexArr):
    print(1)
else:
    print(indexArr.index(min(indexArr))+1)
# print(arrAns, indexArr)


n, k = map(int, input().split())
arr = list(map(int, input().split()))
arrAns = []
for i in range(len(arr)-k):
    arrAns.append(-sum(arr[:i]) + sum(arr[:k+i]))
if(not arrAns):
    print(1)
else:
    print(arrAns.index(min(arrAns))+1)


n, k = map(int, input().split())
arr = list(map(int, input().split()))
arrAns = []
indexArr = []
for i in range(n):
    if(i == 0):
        arrAns.append(arr[0])
    else:
        arrAns.append(arr[i]+arrAns[i-1])
for i in range(n-k):
    if(i==0):
        indexArr.append(arrAns[i+k-1])
    else:
        indexArr.append(arrAns[i+k-1] -arrAns[i-1])

if(not indexArr):
    print(1)
else:
    print(indexArr.index(min(indexArr))+1)


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

mn = float('inf')
sm = 0
for i in range(n):
    if i > k - 1:
        sm += arr[i]
        sm -= arr[i-k]
    else:
        sm += arr[i]

    if i >= k:
        if sm < mn:
            mn = sm
            ind = i

print(ind-1)


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

mn = float('inf')
for i in range(n - (k - 1)):
    sm = sum(arr[i:i+k])
    if sm < mn:
        mn = sm
        ind = i

print(ind+1)


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

mn = float('inf')
sm = 0
ind = 0
for i in range(n):
    if i > k - 1:
        sm += arr[i]
        sm -= arr[i-k]
    else:
        sm += arr[i]

    if i >= k:
        if sm < mn:
            mn = sm
            ind = i- (k - 1)

print(ind+1)


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

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

mx = 1

for i in range(n):
    count = 0

    for j in range(i+1, n):
        if arr[j] <= arr[i]:
            count += 1
        else:
            continue
    mx = max(mx, count)

print(mx)


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

if k == 1:
    mn = float('inf')
    for i in range(n):
        if arr[i] < mn:
            mn = arr[i]
            ind = i
else:
    mn = float('inf')
    sm = 0
    ind = 0
    for i in range(n):
        if i > k - 1:
            sm += arr[i]
            sm -= arr[i-k]
        else:
            sm += arr[i]

        if i > k:
            if sm < mn:
                mn = sm
                ind = i - (k - 1)

print(ind+1)


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

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

mx = 0

for i in range(n):
    count = 0

    for j in range(i+1, n):
        if arr[j] <= arr[i]:
            count += 1
        else:
            continue
    mx = max(mx, count)

print(mx)


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

if k == 1:
    mn = float('inf')
    for i in range(n):
        if arr[i] < mn:
            mn = arr[i]
            ind = i
else:
    mn = float('inf')
    sm = 0
    ind = 0
    for i in range(n):

        if i > k - 1:
            sm += arr[i]
            sm -= arr[i-k]
        else:
            sm += arr[i]

        if i >= k - 1:
            if sm < mn:
                mn = sm
                ind = i - (k - 1)

print(ind+1)


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

if k == 1:
    mn = float('inf')
    for i in range(n):
        if arr[i] < mn:
            mn = arr[i]
            ind = i
else:
    mn = float('inf')
    sm = 0
    ind = 0
    for i in range(n):
        if i > k - 1:
            sm += arr[i]
            sm -= arr[i-k]
        else:
            sm += arr[i]

        if i >= k:
            if sm < mn:
                mn = sm
                ind = i- (k - 1)

print(ind+1)


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

s=0
res=0
for j in range(k):
    res+=l[j]
mini=res
for i in range(1,n-k+1):
    res-=l[i-1]
    res+=l[i+k-1]
    if(res<mini):
        mini=res
        s=i

print(s+1)


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

s=0
res=0
for j in range(k):
    res+=l[j]
mini=res
for i in range(1,n-k):
    res-=l[i-1]
    res+=l[i+k-1]
    if(res<mini):
        mini=res
        s=i

print(s+1)


n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
res=0
for i in range(k):
    res+=l[i]

print(res)


import sys
input = sys.stdin.readline

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

min_hole = 100000000
hole = 0
j = 0
ans = 0
for i in range(0, n):
  if i < k:
    hole += a[i]
  else:
    hole += (a[i]-a[j])
    j += 1
    if min_hole > hole:
      ans = j
      min_hole = hole

print(ans+1)


import sys
input = sys.stdin.readline

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

min_hole = 0
hole = 0
j = 0
ans = 0
for i in range(0, n):
  if i < k:
    hole += a[i]
    min_hole = hole
  else:
    hole += (a[i]-a[j])
    j += 1
    if min_hole > hole:
      ans = j
      min_hole = hole

print(ans+1)


import sys
planks, consecutive = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
ans = arr[0: consecutive]
ans = sum(ans)
final = 1
try:
    for index, x in enumerate(range(1, planks)):
        temp = arr[x: consecutive]
        temp = sum(temp)
        if temp < ans:
            final = index + 1
            ans = temp
except IndexError:
    pass

sys.stdout.write(str(final))


import sys
planks, consecutive = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
ans = arr[0: consecutive]
ans = sum(ans)
final = 1
for index, x in enumerate(range(1, planks - (consecutive - 1))):
    temp = arr[x: consecutive + index + 1]
    temp = sum(temp)
    if temp < ans:
        final = x + 1
        ans = temp

sys.stdout.write(str(final))


import sys
planks, consecutive = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
ans = arr[0: consecutive]
ans = sum(ans)
lowest = int(ans)
final = 1
for index, x in enumerate(range(1, planks - (consecutive - 1))):
    temp = (ans - arr[x - 1]) + arr[consecutive + index]
    if temp < lowest:
        lowest = temp
        final = x + 1
    ans = int(temp)

sys.stdout.write(str(final))


n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
s = 0
for i in range(k):
    s += h[i]
minSum = s
for i in range(k, n):
    s -= h[i - k]
    s += h[i]
    if minSum > s:
        minSum = s
print(minSum)


n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
s = 0
for i in range(k):
    s += h[i]
minSum = s
minJ = 1
for i in range(k, n):
    s -= h[i - k]
    s += h[i]
    if minSum > s:
        minSum = s
        minJ = i - k + 2
print(minJ)


n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
s = 0
for i in range(k):
    s += h[i]
minSum = s
minJ = 0
for i in range(k, n):
    s -= h[i - k]
    s += h[i]
    if minSum > s:
        minSum = s
        minJ = i - k + 2
print(minJ)


n, k = map(int, input().rstrip().split(" "))
l = list(map(int, input().rstrip().split(" ")))
res = [0]*(n-k+1)
s = sum(l[:k])
res[0]=s
lo = n-k
if k == 1:
    print(l.index(min(l))+1)
else:
    for i in range(0, lo):
        s = s - l[i] + l[k+i]
        res[i+1]=s
    print(res.index(min(res))+1)


n, k = map(int, input().rstrip().split(" "))
l = list(map(int, input().rstrip().split(" ")))
if k == 1:
    print(l.index(min(l))+1)
else:
    m = 999999999999999
    mi = 0
    for i in range(n-k):
        x =sum(l[i:i+k])
        if x<m:
            m = x
            mi = i
    print(mi+1)


n, k = map(int, input().rstrip().split(" "))
l = list(map(int, input().rstrip().split(" ")))
if k == 1:
    print(min(l))
else:
    m = 999999999999999
    mi = 0
    for i in range(n-k):
        x =sum(l[i:i+k])
        if x<m:
            m = x
            mi = i
    print(mi+1)


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define in freopen( "in.txt" , "r", stdin );
#define out freopen( "out.txt", "w", stdout );
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
const ll N = 1e6+5;
ll n, a[N], mx, l[N], cnt;
int main()
{
    TIME;
    cin >> n;
    for ( int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
    }
    for ( int i = n; i >= 1; i -- )
    {
        mx = max( mx, a[i] );
        if ( a[i] < mx )
        {
            cnt ++;
            l[cnt] = mx - a[i] + 1;
        }
        else {
            cnt ++;
            l[cnt] = 0;
        }
    }
    for ( int i = n; i >= 1; i -- )
    {
        cout << l[i] << " ";
    }
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define in freopen( "in.txt" , "r", stdin );
#define out freopen( "out.txt", "w", stdout );
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
const ll N = 1e6+5;
ll n, a[N], mx, l[N], cnt;
int main()
{
    TIME;
    cin >> n;
    for ( int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
    }
    for ( int i = n; i >= 1; i -- )
    {
        mx = max( mx, a[i] );
        if ( a[i] < mx )
        {
            cnt ++;
            l[cnt] = mx - a[i] + 1;
        }
        else {
            cnt ++;
            l[cnt] = 0;
        }k
    }
    for ( int i = n; i >= 1; i -- )
    {
        cout << l[i] << " ";
    }
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define in freopen( "in.txt" , "r", stdin );
#define out freopen( "out.txt", "w", stdout );
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
const ll N = 1e6+5;
ll n, a[N], mx, l[N], cnt;
int main()
{
    TIME, in out
    cin >> n;
    for ( int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
    }
    for ( int i = n; i >= 1; i -- )
    {
        if ( a[i] < mx )
        {
            cnt ++;
            l[cnt] = mx - a[i] + 1;
        }
        else {
            cnt ++;
            l[cnt] = 0;
        }
        mx = max( mx, a[i] );
    }
    for ( int i = n; i >= 1; i -- )
    {
        cout << l[i] << " ";
    }
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define se second
#define in freopen( "in.txt" , "r", stdin );
#define out freopen( "out.txt", "w", stdout );
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
const ll N = 1e6+5;
ll n, a[N], mx, l[N], cnt;
int main()
{
    TIME;
    cin >> n;
    for ( int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
    }
    for ( int i = n; i >= 1; i -- )
    {
        if ( a[i] < mx )
        {
            cnt ++;
            l[cnt] = mx - a[i] + 1;
        }
        else {
            cnt ++;
            l[cnt] = 0;
        }
        mx = max( mx, a[i] );
    }
    for ( int i = n; i >= 1; i -- )
    {
        cout << l[i] << " ";
    }
}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){

    int n,a[100005];
    cin>>n;

    REP(i,n){
        cin>>a[i];
    }

    int mx = 0;

    CREP(i,n){
        int t = a[i];
        a[i] = max(mx-a[i]+1, 0);
        mx = max(mx, t);
    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){
    fastio;
    int n,a[100005];
    cin>>n;
    std::vector<pair<int,int> > v;

    REP(i,n){
        cin>>a[i];
    }

    if(std::is_sorted(a,a+n,[&](int &a,int &b){
        return a>b;
    })){
        REP(i,n){
            cout<<"0 ";
        }
        return 0;
    }

    int i = 0;
    while(i < n){

        int mx = *max_element(a+i,a+n);
        int index ;
        for(int j = i; j<n; j++){
            if(mx == a[j]){
                index = j;
            }
        }

        for(int j = i; j < index; j++){
            a[j] = mx - a[j] + 1;
        }
        a[index] = 0;
        i = index+1;

    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){
    fastio;
    int n,a[100005];
    cin>>n;
    std::vector<pair<int,int> > v;
    int cn = 0, ln = 0;
    REP(i,n){
        cin>>a[i];
    }

    MYREP(i,1,n-1){
        if(a[i] == a[i-1]-1){
            cn++;
        }
        if(a[i] == a[i-1]+1){
            ln++;
        }
    }
    if(cn == n-1){
        REP(i,n){
            cout<<"0 ";
        }
        return 0;
    }
    if(ln == n-1){
        REP(i,n-1){
            cout<<a[n-1]-i<<" ";
        }
        cout<<0;
        return 0;
    }

    int i = 0;
    while(i < n){

        int mx = *max_element(a+i,a+n);
        int index ;
        for(int j = i; j<n; j++){
            if(mx == a[j]){
                index = j;
            }
        }

        for(int j = i; j < index; j++){
            a[j] = mx - a[j] + 1;
        }
        a[index] = 0;
        i = index+1;

    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){
    fastio;
    int n,a[100005];
    cin>>n;

    REP(i,n){
        cin>>a[i];
    }

    int mx = 0;

    CREP(i,n){
        int t = a[i];
        a[i] = max(mx-a[i]+1, 0);
        mx = max(mx, t);
    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){
    fastio;
    int n,a[100005];
    cin>>n;
    std::vector<pair<int,int> > v;

    REP(i,n){
        cin>>a[i];
    }
    int i = 0;
    while(i < n){

        int mx = *max_element(a+i,a+n);
        int index ;
        for(int j = i; j<n; j++){
            if(mx == a[j]){
                index = j;
            }
        }

        for(int j = i; j < index; j++){
            a[j] = mx - a[j] + 1;
        }
        a[index] = 0;
        i = index+1;

    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){
    fastio;
    int n,a[100005];
    cin>>n;
    std::vector<pair<int,int> > v;
    int cn = 0, ln = 0;
    REP(i,n){
        cin>>a[i];
    }

    MYREP(i,1,n-1){
        if(a[i] == a[i-1]-1){
            cn++;
        }
        if(a[i] == a[i-1]+1){
            ln++;
        }
    }
    if(cn == n-1){
        REP(i,n){
            cout<<"0 ";
        }
        return 0;
    }
    if(ln == n-1){
        REP(i,n){
            cout<<"1 ";
        }
        return 0;
    }

    int i = 0;
    while(i < n){

        int mx = *max_element(a+i,a+n);
        int index ;
        for(int j = i; j<n; j++){
            if(mx == a[j]){
                index = j;
            }
        }

        for(int j = i; j < index; j++){
            a[j] = mx - a[j] + 1;
        }
        a[index] = 0;
        i = index+1;

    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


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

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL              long long
#define LD              long double
#define MAX             200005
#define MOD             1000000007
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define aLL(c)          (c).begin(),(c).end()
#define aLLr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(aLL(c),x) != (c).end())

int main(){

    int n,a[100005];
    cin>>n;
    std::vector<pair<int,int> > v;

    REP(i,n){
        cin>>a[i];
    }
    int i = 0;
    while(i < n){

        int mx = *max_element(a+i,a+n);
        int index ;
        for(int j = i; j<n; j++){
            if(mx == a[j]){
                index = j;
            }
        }

        for(int j = i; j < index; j++){
            a[j] = mx - a[j] + 1;
        }
        a[index] = 0;
        i = index+1;

    }

    REP(i,n){
        cout<<a[i]<<" ";
    }

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx;
	vector<int>v(a, a + n);
	for (int i = 0; i < n; i++)
	{
		sort(v.begin() + i, v.end());
		mx = v[v.size() - 1];
		if (mx <= a[i])
		{
			cout << 0 << ' ';
		}
		else	cout << mx  - a[i] + 1 << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx;
	vector<int>v(a, a + n);
	for (int i = 0; i < n; i++)
	{
		vector<int>v(a , a + n);
		sort(v.begin() + i, v.end());
		mx = v[v.size() - 1];
		if (mx <= a[i])
		{
			cout << 0 << ' ';
		}
		else	cout << mx  - a[i] + 1 << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx = a[n-1];
	vector<int>v;
	v.push_back(0);
	for (int i = n - 2; i >= 0; i--)
	{
		mx = max(mx, a[i + 1]);
		if (mx > a[i])
		{
			v.push_back(mx - a[i] + 1);
		}
		else
			v.push_back(0);
	}
	for (int i = v.size() - 1; i >= 0; i--)
	{
		cout << v[i] << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx;
	for (int i = 0; i < n; i++)
	{
		mx = *max_element(a + i , a + n);
		if (mx <= a[i])
		{
			cout << 0 << ' ';
		}
		else	cout << mx - a[i] + 1 << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx = a[n-1];
	vector<int>v;
	v.push_back(0);
	for (int i = n - 2; i >= 0; i--)
	{
		mx = max(mx, a[i + 1]);
		v.push_back(max(mx - a[i] + 1, 0));
	}
	for (int i = v.size() - 1; i >= 0; i--)
	{
		cout << v[i] << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx;
	for (int i = 0; i < n; i++)
	{
		vector<int>v(a + i, a + n);
		sort(v.begin(), v.end());
		mx = v[v.size() - 1];
		if (mx <= a[i])
		{
			cout << 0 << ' ';
		}
		else	cout << mx  - a[i] + 1 << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx;
	for (int i = 0; i < n; i++)
	{
		vector<int>v(a , a + n);
		sort(v.begin() + i, v.end());
		mx = v[v.size() - 1];
		if (mx <= a[i])
		{
			cout << 0 << ' ';
		}
		else	cout << mx  - a[i] + 1 << ' ';
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n, *a; cin >> n; a = new int[n]; for (int i = 0; i < n; i++)cin >> a[i];
	int mx = a[n-1];
	vector<int>v;
	v.push_back(0);
	for (int i = n - 2; i >= 0; i--)
	{
		mx = max(mx, a[i]);
		if (a[i] < mx)
		{
			v.push_back(mx - a[i] + 1);
		}
		else
			v.push_back(0);
	}
	for (int i = v.size() - 1; i >= 0; i--)
	{
		cout << v[i] << ' ';
	}
	cout << endl;
	return 0;
}


#include <iostream>
using namespace std;
const int maxn=1e5+100;
int a[maxn] , ans[maxn];
int main()
{
    int n , mx;
    cin>>n;
    for( int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    mx=a[n-1];
    for( int i=n-1 ; i >= 0 ; i--)
    {
        if( mx > a[i] )
            ans[i]=(mx-a[i])+1;
        if( mx < a[i])
            mx=a[i];
    }
    for( int i=0 ; i<n ; i++)
        cout<<ans[i]<<" ";
    return 0;
}


#include <iostream>
using namespace std;
const int maxn=1e5+100;
int a[maxn] , ans[maxn];
int main()
{
    int n , mx;
    cin>>n;
    for( int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    mx=a[n-1];
    for( int i=n-1 ; i >= 0 ; i--)
    {
        if( mx >= a[i] )
            ans[i]=(mx-a[i])+1;
        if( mx < a[i])
            mx=a[i];
    }
    for( int i=0 ; i<n ; i++)
        cout<<ans[i]<<" ";
    return 0;
}


#include <iostream>
using namespace std;
const int maxn=1e6+100;
int a[maxn] , ans[maxn];
int main()
{
    int n , mx=0;
    cin>>n;
    for( int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    mx=a[n-1];
    for( int i=n-2 ; i >= 0 ; i--)
    {
        if( mx > a[i] )
            ans[i]=mx-a[i]+1;
        else
            ans[i]=0;
        mx=max( mx , a[i]);
    }
    for( int i=0 ; i<n ; i++)
        cout<<ans[i]<<" ";
    return 0;
}


#include <iostream>
using namespace std;
const int maxn=1e5+100;
int a[maxn] , ans[maxn];
int main()
{
    int n , mx;
    cin>>n;
    for( int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    mx=a[n-1];
    for( int i=n-2 ; i >= 0 ; i--)
    {
        if( mx > a[i] )
            ans[i]=mx-a[i]+1;
        else
            ans[i]=0;
        if( mx < a[i])
            mx=a[i];
    }
    for( int i=0 ; i<n ; i++)
        cout<<ans[i]<<" ";
    return 0;
}


#include <iostream>
using namespace std;
const int maxn=1e6+100;
int a[maxn] , ans[maxn];
int main()
{
    int n , mx=0;
    cin>>n;
    for( int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    mx=a[n-1];
    for( int i=n-2 ; i >= 0 ; i--)
    {
        if( mx > a[i] )
        {
            ans[i]= mx-a[i]+1;
            mx=max( mx , a[i]);
            continue;
        }
        else
        {
            ans[i]=0;
            mx=max( mx , a[i]);
            continue;
        }

    }
    for( int i=0 ; i<n ; i++)
        cout<<ans[i]<<" ";
    return 0;
}