Given a sequence of numbers a1, a2, …, a15, ordered in ascending order, and a number n1

Given a sequence of numbers a1, a2, …, a15, ordered in ascending order, and a number n1 that is not equal to any of the numbers in the sequence, and such that a1

program zz1;
const n = 7; // set the number of elements in the array
A: array [1..n] of integer = (4, 5, 5, 6, 7, 9, 16); // set a sequence of numbers
var i, k, M, n1: integer; // set variables of integer type
begin
writeln (‘enter the given n1’);
read (n1);
for i: = 1 to n do // organize a loop in which we iterate over all the elements of the array
if A [i] = n1 then k: = i; // find the given number n1 in the sequence and remember its number
for i: = 1 to k-1 do // organize a loop up to a given number
M: = M + A [i]; // calculate the amount
write (‘the sum of a sequence of numbers less than n1 =’, M); // display the answer
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.