Program HOC24;
var i,n: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=a[1]+a[n];
write('Ket qua la: ',t);
readln
end.
program TinhTongPhanTuDauVaPhanTuCuoi;
var
A: array[1..1000] of integer;
n, TongDau, TongCuoi: integer;
i: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('A[', i, '] = ');
readln(A[i]);
end;
TongDau := A[1];
TongCuoi := A[n];
writeln('Cac phan tu trong mang la: ');
for i := 1 to n do
begin
write(A[i], ' ');
if i = 1 then
continue;
if i = n then
break;
TongDau := TongDau + A[i];
end;
writeln();
writeln('Tong phan tu dau va phan tu cuoi cua mang la: ', TongDau + TongCuoi);
readln;
end.