package yukicoder; import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args){ new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int[] d=new int[m]; int min_d=999999999; for(int i=0;i0)return Math.min(-2*left+right,-left+2*right); if(left>=0&&right>0)return right; else return -1;//error } }