       IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(11000).
       01 A-REC.
      	02 A-DATA OCCURS 100.
      	 03 A PIC 999.
       01 B PIC 999.
       01 C PIC 999.
       01 D PIC 999.
       01 ALICE PIC 999999.
       01 BOB PIC 999999.
       01 REN PIC 9999999999.
       01 RE PIC ZZZZZZZZZZ9.
       01 temp1 PIC 9999999.
       01 temp2 PIC 9999999.
       01 temp3 PIC 9999999.
       01 NOW PIC 9999999.
       01 N PIC 999.
       01 MAX PIC 999.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT B.
      	ACCEPT INP.
      	ADD 1 TO B.
      	MOVE 1 TO NOW.
      	PERFORM VARYING C FROM 1 BY 1 UNTIL C = B
      		PERFORM VARYING temp1 FROM NOW BY 1 
      				UNTIL INP(temp1:1) = SPACE
			END-PERFORM
      		COMPUTE N = temp1 - NOW
      		MOVE INP(NOW:N) TO A(C)
      		COMPUTE NOW = NOW + N
      	END-PERFORM.
      	PERFORM VARYING C FROM 1 BY 1 UNTIL C = B
      		MOVE C TO MAX
      		PERFORM VARYING D FROM C BY 1 UNTIL D = B
      			IF A(D) >= A(MAX) THEN
      				MOVE D TO MAX
      			END-IF
      		END-PERFORM
      		COMPUTE temp1 = A(C)
      		COMPUTE A(C) = A(MAX)
      		COMPUTE A(MAX) = temp1
      	END-PERFORM.
      	MOVE 0 TO ALICE.
      	MOVE 0 TO BOB.
      	PERFORM VARYING C FROM 1 BY 1 UNTIL C = B
      		COMPUTE ALICE = ALICE + A(C)
      		ADD 1 TO C
      		COMPUTE BOB = BOB + A(C)
      	END-PERFORM.
		COMPUTE REN = ALICE - BOB.
      	MOVE REN TO RE.
      	DISPLAY RE.
      	STOP RUN.