program ideone;
VAR
count1:integer;
count2:integer;
count3:integer;
count4:integer;
count5:integer;
string1:array[0..75]of char;
amt1:array[0..15]of integer;
amt2:array[0..15]of integer;
amt3:array[0..15]of integer;
amt4:array[0..15]of integer;
amt5:array[0..15]of integer;
sum_1:integer;
sum_2:integer;
sum_3:integer;
sum_4:integer;
sum_5:integer;
mas_name:char;
c_cost:real;
section1:char;
section2:char;
section3:char;
section4:char;
section5:char;
amt_paid:integer;

section_counter:array[0..4] of integer;
section_pay:array[0..4] of integer;
total_paid:integer;
exit_flag:boolean;
exit_input:string;
i:integer;

BEGIN
 // This initializes the exit flag, ensuring that we enter the main loop.
 exit_flag := true;
 
 // This initializes our counters and amount paid for each section.
 for i:= 0 to 4 do 
 begin
     section_counter[i] := 0;
     section_pay[i] := 0;
 end;
 
 // This initializes our total paid.
 total_paid := 0;
 
 // Welcome message.
 Writeln('****WELCOME TO THE COMMAZ BAND EXCLUSIVE CARNIVAL. FOLLOW THE INSTRUCTIONS THAT ARE GIVEN.****');

 // We enter the loop here.
 while(exit_flag) do
 begin
	 Writeln('Enter the Masqueraders name: ');
	 readln(string1);
	 Writeln('Enter the cost of the costume: ');
	 readln(c_cost);
	 Writeln('Enter the Amount Paid by the Masquerader: ');
	 readln(amt_paid);
	 // Section 1.
	 if ((amt_paid = 144) or (amt_paid = 184)) then
	 begin
	      // Section 1.
	      Writeln('THIS MASQUERADER IS IN SECTION:  Section 1');
	      Inc(section_counter[0]);
	      section_pay[0] += amt_paid;
	      total_paid += amt_paid;
	 end
	 else if ((amt_paid = 198) or (amt_paid = 253)) then
	 begin
	      // Section 2.
	      Writeln('THIS MASQUERADER IS IN SECTION:  Section 2');
	      Inc(section_counter[1]);
	      section_pay[1] += amt_paid;
	      total_paid += amt_paid;
	 end
	 else if ((amt_paid = 252) or (amt_paid = 322)) then
	 begin
	      // Section 3.
	      Writeln('THIS MASQUERADER IS IN SECTION:  Section 3');
	      Inc(section_counter[2]);
	      section_pay[2] += amt_paid;
	      total_paid += amt_paid;
	 end
	 else if ((amt_paid = 315) or (amt_paid = 405)) then
	 begin
	      // Section 4.
	      Writeln('THIS MASQUERADER IS IN SECTION:  Section 4');
	      Inc(section_counter[3]);
	      section_pay[3] += amt_paid;
	      total_paid += amt_paid;
	 end
	 else if ((amt_paid =383) or (amt_paid = 489)) then
	 begin
	      // Section 5.
	      Writeln('THIS MASQUERADER IS IN SECTION:  Section 4');
	      Inc(section_counter[4]);
	      section_pay[4] += amt_paid;
	      total_paid += amt_paid;
	 end;
    
      // Now that we've finished one run-through of the program, we ask if
      // we want to do this again.
      
      Writeln('Do you want to add another masquerader? Input Yes to do so.');
      readln(exit_input);
      
      if((exit_input <> 'yes') and (exit_input <> 'YES') 
                               and (exit_input <> 'Yes')) then
      begin
          exit_flag := false;
      end;
  end;
  
  // Now that we're out of the loop, we print everything.
  
  Writeln('Totals for each section:');
  
  for i:= 0 to 4 do 
  begin
      write('Section ', i + 1, '\n');
      write('Number of masqueraders: ', section_counter[i], '\n');
      write('Amount paid: ', section_pay[i], '\n');
      Writeln();
  end;
  
  write('Total paid: ', total_paid, '\n')
      
      
END.