Pagini recente » Cod sursa (job #2921902) | Cod sursa (job #2618960) | Cod sursa (job #3180594) | Cod sursa (job #692296) | Cod sursa (job #60582)
Cod sursa(job #60582)
var f1,f2:text; i,j,caut,n,h,r:longint;
y,z,v,a:array[-9000..9000] of longint;
nr:int64;
begin
assign(f1,'medie.in');
reset(f1);
assign(f2,'medie.out');
rewrite(f2);
read(f1,n);
r:=0;
for i:=1 to n do
begin
read(f1,a[i]);
h:=1;
for j:=1 to r do
begin
if y[j]=a[i] then
begin
h:=0;
inc(z[j]);
end;
end;
if h=1 then
begin
inc(r);
y[r]:=a[i];
inc(z[r]);
end;
end;
for i:=1 to n do
begin
for j:=1 to r do
begin
v[y[j]]:=z[j];
end;
caut:=2*a[i];
dec(v[a[i]]);
for j:=1 to n do
begin
if j<>i then dec(v[a[j]]);
if (j<>i)and(caut-a[j]>0) then nr:=nr+v[caut-a[j]];
end;
end;
writeln(f2,nr);
close(f1);
close(f2);
end.