// Originally written by: Ches and Guillermo
//                        during the 2006 Week #2 Practice Contest
// Edited in class on 7/27/06 for the purpose of displaying
// debugging techniques. Ultimately, this solution ends up being a
// bit more elegant than the other posted solution.

import java.util.*;
import java.io.*;

public class jars1 {
	
	public static void main(String[] args) throws IOException{

     		// Set up reading from the input file.		
		Scanner fin = new Scanner (new File("jars.in"));
		double remain = 0;

		// Read in the capacity of your container and the number
		// of other containers.
		int cap = fin.nextInt();
		int found = fin.nextInt();

		// This array isn't necessary, but was in the original code
		// from Ches and Guillermo. Since it does not detract from
		// the solution, it has been left in.
		double[] j = new double[found];

		// Read in all the container sizes into the array.
		for(int i = 0; i < j.length; i++){
			j[i] = fin.nextDouble();
		}
		
		// Will keep track of the current amount of liquid in the current
		// container being filled.
		double current = 0;
		
		// Loop through each container in order.
		for(int i = 0;i < j.length; i++){
			
			// Adding next "bottle" to my container.
			current = current + j[i];		
			
			// If we get an overflow, calculate the extra fluid
			// and start with a new container to fill.
			if (current >= cap) {
				remain = remain + current - cap;
				current = 0;		
			}	
		}
	
		// Output the result.	
		System.out.println("The volume of the leftover chemical will be "+remain+" cm^3.");
	}
		
}
