// Arup Guha
// Solution to 2006 MCPC Regional Problem D: Falling Ice
// 1/19/2014

/*** Note: This is a very hacky solution, that takes care of weird individual cases one by one
 *         This passes the judge data but very well may not work in general.
 ***/

import java.util.*;

public class d {

	final public static double EPSILON = 0.0000000001;

	// hasAdjacent[i][j] stores radius of largest mutually tangent circle to circles i and j.
	public static int[][] adjRadius;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int W = stdin.nextInt();

		// Go through each case.
		while (W != 0) {

			// Read in the circles.
			int n = stdin.nextInt();
			circle[] ice = new circle[n];
			adjRadius = new int[n][n];
			for (int i=0; i<n; i++) {
				int r = stdin.nextInt();
				ice[i] = new circle(r);
			}

			// Output the solution and go to the next case.
			System.out.printf("%.2f\n",solve(ice, W));
			W = stdin.nextInt();
		}
	}

	public static double solve(circle[] ice, int W) {

		// First one must go here.
		ice[0].setXY(ice[0].r, ice[0].r);

		// Try placing each circle.
		for (int i=1; i<ice.length; i++) {
			double[] ans = solveXY(ice, W, i);
			ice[i].setXY(ans[0], ans[1]);
		}

		// Find the highest point on any circle and return.
		double ans = ice[0].y + ice[0].r;
		for (int i=1; i<ice.length; i++)
			if (ice[i].y+ice[i].r > ans)
				ans = ice[i].y+ice[i].r;

		return ans;
	}

	public static double[] getGround(circle[] ice, int W, int curIndex) {

		// Preprocessing step to see if this circle can fit through the hole.
		for (int i=curIndex-1; i>=0; i--) {

			circle c1 = ice[i];
			circle c2 = ice[curIndex];

			// No need to fit through, because the new circle will "sit on top" of circle i.
			if (c2.r > c1.y) continue;

			// Can't fit through condition.
			if (c1.x+c1.r+2*c2.r > W) return null;
		}

		// Go backwards through the previous circles.
		for (int i=curIndex-1; i>=0; i--) {

			circle c1 = ice[i];
			circle c2 = ice[curIndex];

			// Greedy step to skip over any item not on the ground as a limiting object.
			// Not sure if this is valid.
			if (!c1.onGround()) continue;

			// Figure out where this circle would go.
			double hyp = c1.r + c2.r;
			double s = Math.abs(c1.r-c2.r);
			double dx = Math.sqrt(hyp*hyp-s*s);
			double[] ans = new double[2];
			ans[0] = c1.x + dx;
			ans[1] = c2.r;
			circle temp = new circle(c2.r, ans[0], ans[1]);

			// Double check that it doesn't hit another circle.
			if (!isValid(ice, W, curIndex, temp)) continue;

			// If we pass the check, we're good.
			return ans;
		}

		// Should never get here.
		return null;
	}

	public static double[] solveXY(circle[] ice, int W, int curIndex) {

		// First try placing on the ground.
		double[] tryCoord = getGround(ice, W, curIndex);
		if (tryCoord != null) return tryCoord;

		int tryI = -1, tryJ = -1;
		double[] best = new double[2];
		best[1] = 10000000;

		// Checks all places where the new circle is tangent to two old circles.
		for (int i=0; i<curIndex; i++) {
			for(int j=i+1; j<curIndex; j++) {

				// The current circle goes through these 2 can can't be tangent to both.
				if (ice[i].dist(ice[j]) > 2*ice[curIndex].r) continue;

				// Can't consider a pair that already has adjacent a circle adjacent to it that is smaller.
				// Pretty tricky case...
				if (adjRadius[i][j] > ice[curIndex].r) continue;

				double[] center = getCenter(ice[i], ice[j], ice[curIndex]);
				circle temp = new circle(ice[curIndex].r, center[0], center[1]);

				// Best we've seen, so update.
				if (isValid(ice, W, curIndex, temp) && center[1] < best[1]) {
					tryI = i;
					tryJ = j;
					best = center;
				}
			}
		}

		// Try the two walls.
		double[] left = solveWall(ice, ice[curIndex].r, W, curIndex);
		if (left[1] < best[1]) {
			tryI = -1;
			best = left;
		}

		double[] right = solveWall(ice, W-ice[curIndex].r, W, curIndex);
		if (right[1] < best[1]) {
			tryI = -1;
			best = right;
		}

		// Update the largest radius adjacent to circles tryI and tryJ, if necessary.
		if (tryI >= 0) {
			adjRadius[tryI][tryJ] = (int)ice[curIndex].r;
			adjRadius[tryJ][tryI] = (int)ice[curIndex].r;
		}

		return best;
	}

	public static double[] solveWall(circle[] ice, double setX, int W, int curIndex) {

		circle c = ice[curIndex];

		// Where we would be against the wall.
		double[] ans = new double[2];
		ans[0] = setX;
		ans[1] = 0;

		// Try all previous circles.
		for (int i=0; i<curIndex; i++) {

			double dist = ice[i].r + c.r;
			double x = ice[i].x - ans[0];

			// Avoid negative square root...case where this circle can't touch circle i and the wall.
			if (dist*dist < x*x) continue;

			// Here is where the circle would be wedged.
			double diffy = Math.sqrt(dist*dist-x*x);
			double tempy = ice[i].y + diffy;

			// We want the highest of the valid circles.
			circle temp = new circle(c.r, setX, tempy);
			if (isValid(ice, W, curIndex, temp) && tempy > ans[1])
				ans[1] = tempy;
		}

		return ans;
	}

	// c3 doesn't have a position yet.
	public static double[] getCenter(circle c1, circle c2, circle c3) {

		// Set up law of cosines for three adjacent circles, c1, c2 and c3.
		double s1 = c1.r + c3.r;
		double s2 = c1.distCenters(c2);
		double s3 = c2.r + c3.r;
		double angle = Math.acos((s1*s1+s2*s2-s3*s3)/(2*s1*s2));

		// Angle from c1 to c2 (centers).
		double refangle = Math.atan2(c2.y-c1.y, c2.x-c1.x);

		// Try the offest in both directions, since we don't know which way is up.
		double angle1 = refangle + angle;
		double[] ans1 = new double[2];
		ans1[0] = c1.x + s1*Math.cos(angle1);
		ans1[1] = c1.y + s1*Math.sin(angle1);

		double angle2 = refangle - angle;
		double[] ans2 = new double[2];
		ans2[0] = c1.x + s1*Math.cos(angle2);
		ans2[1] = c1.y + s1*Math.sin(angle2);

		// We want to return the higher point.
		if (ans1[1] > ans2[1]) return ans1;
		return ans2;
	}

	public static boolean isValid(circle[] ice, int W, int curIndex, circle cur) {

		// Too far left or right.
		if (cur.x-cur.r + EPSILON < 0 || cur.x+cur.r - EPSILON > W) return false;
		if (cur.y-cur.r + EPSILON < 0) return false;

		// Intersecting with another circle.
		for (int i=0; i<curIndex; i++)
			if (ice[i].dist(cur) < -EPSILON)
				return false;

		return true;
	}
}

class circle {

	public double r;
	public double x;
	public double y;

	// Note: center will be set later...
	public circle(int diameter) {
		r = diameter/2.0;
		x = 0;
		y = 0;
	}

	public circle(double myr, double myx, double myy) {
		r = myr;
		x = myx;
		y = myy;
	}

	public void setXY(double myx, double myy) {
		x = myx;
		y = myy;
	}

	// return distance between circles.
	public double dist(circle other) {
		return distCenters(other) - r - other.r;
	}

	public double distCenters(circle other) {
		return Math.sqrt(Math.pow(x-other.x,2) + Math.pow(y-other.y,2));
	}

	public boolean onGround() {
		return Math.abs(y-r) < d.EPSILON;
	}
}