// Arup Guha
// 6/21/2020
// Solution to 2020 January Bronze USACO Problem: Race

// Note sure what happened here. This is a problem that would have been easy for the young me, and gave the
// current me fits. Not sure why.

import java.util.*;
import java.io.*;

public class race {
	
	public static void main(String[] args) throws Exception {
		
		Scanner stdin = new Scanner(new File("race.in"));
		int len = stdin.nextInt();
		int numQ = stdin.nextInt();
		PrintWriter out = new PrintWriter(new FileWriter("race.out"));

		// Process all queries.
		for (int loop=0; loop<numQ; loop++) {
			int endSpeed = stdin.nextInt();
			out.println(solve(len, endSpeed));
		}
		
		out.close();		
		stdin.close();
	}
	
	public static long solve(long len, long endSpeed) {
		
		// We never have to go faster than this.
		endSpeed = Math.min(endSpeed, 45000);
		
		// For first endSpeed secs.
		long tri = (endSpeed*(endSpeed+1))/2;
		
		// Just keep increasing till the end.
		if (tri >= len) return getTriNumber(len);
		
		// Answer for going to endSpeed and staying there.
		long res = endSpeed + (len-tri)/endSpeed;
		if ((len-tri)%endSpeed != 0) res++;
		
		// Just try each ending speed.
		for (long last=endSpeed+1; last<=45000; last++) {
			
			// Run up to last, and down to endSpeed.
			long left = len - last*(last+1)/2 - (last-1+endSpeed)*(last-endSpeed)/2;
			
			if (left < 0) break;
			
			// This is the time taken.
			long tmp = 2*last-endSpeed;
			
			// Add to the time running at the top speed.
			tmp += left/last;
			
			// Add one more.
			if (left%last != 0) tmp++;
			
			// Take the minimum.
			res = Math.min(res, tmp);
		}
		
		// return.
		return res;
	}
	
	// Find min n such that n*(n+1)/2 >= sum.
	public static long getTriNumber(long sum) {
		
		long low = 0, high = sum;
		
		// Set up search.
		while (low < high) {
			
			// Guess.
			long mid = (low+high)/2;
			
			// Check it, update accordingly.
			if ( (mid*(mid+1))/2 >= sum )
				high = mid;
			else
				low = mid+1;
		}
		
		// Ta da!
		return low;
	}
}