program QUATANG;
uses crt;
var n,i,j,k,dem:word;
tb,t:real;
a:array[1..500] of longint;
f:text;
str:string;
begin
clrscr;
writeln;
assign(f,'D:\QUATANG.INP');
reset(f);
readln(f,n);
for i:=1 to n do read(f,a
);
close(f);
writeln('du lieu nhap vao tep QUATANG.INP la:');
reset(f);
while not eof(f) do
begin
readln(f,str);
writeln(str);
end;
close(f);
assign(f,'D:\QUATANG.OUT');
rewrite(f);
dem:=0; t:=0;
i:=1;
while i<=n do
begin
tb:=a;
j:=1;
if i=j then inc(j);
while a[j]<>a do
begin
k:=j+1;
while a[k]<>a[j] do
begin
if (tb=((a[j]+a[k])/2)) and (a<>t) then
begin
t:=tb;
dem:=dem+1;
end;
inc(k);
if k>n then break;
end;
inc(j);
if j=n then break;
end;
inc(i);
end;
write(f,dem);
close(f);
writeln;
writeln('du lieu ghi ra tep QUATANG.OUT la:');
reset(f);
while not eof(f) do
begin
readln(f,str);
writeln(str);
end;
close(f);
readln;
end.
chúc bạn học tốt