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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int K = Integer.parseInt(st.nextToken()); K Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st double[] arr = new double[N]; arr new double[N] N st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		} {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		} arr[i] = Integer.parseInt(st.nextToken()) arr[i] arr i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st arr[i] /= K arr[i] arr i K double max = 1.0 + arr[0] - arr[N - 1]; max 1.0 + arr[0] - arr[N - 1] 1.0 + arr[0] 1.0 arr[0] arr 0 arr[N - 1] arr N - 1 N 1 for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		} int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
			max = Double.max(max, arr[i + 1] - arr[i]);
		} {
			max = Double.max(max, arr[i + 1] - arr[i]);
		} max = Double.max(max, arr[i + 1] - arr[i]) max Double.max(max, arr[i + 1] - arr[i]) Double.max Double max arr[i + 1] - arr[i] arr[i + 1] arr i + 1 i 1 arr[i] arr i System.out.println(Math.round((1 - max) * K)) System.out.println System.out System System.out Math.round((1 - max) * K) Math.round Math (1 - max) * K (1 - max) 1 max K String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int K = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		double[] arr = new double[N];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			arr[i] /= K;
		}
		double max = 1.0 + arr[0] - arr[N - 1];
		for (int i = 0; i < N - 1; i++) {
			max = Double.max(max, arr[i + 1] - arr[i]);
		}
		System.out.println(Math.round((1 - max) * K));
	}
}