Pagini recente » Diferente pentru olimpici intre reviziile 95 si 94 | Istoria paginii runda/usu2/clasament | Istoria paginii runda/pc_11a/clasament | Cod sursa (job #151421) | Cod sursa (job #431350)
Cod sursa(job #431350)
#include<stdio.h>
#include<algorithm>
#define ll long long
using namespace std;
const int N=9001;
int n,v[N],c[N];
long long rez;
void read()
{
scanf("%d",&n);
for( int i=1 ; i<=n ; ++i )
{
scanf("%d",&c[i]);
++v[c[i]];
}
sort(c+1,c+n+1);
}
void solve()
{
int i,j,t;
for (i=1; i<n; i++)
for (j=i+1; j<=n && 2*c[j]-c[i]<=v[n]; j++)
{
t=2*c[j]-c[i];
if (c[i]!=c[j])
rez+=v[t];
else
rez+=v[t]-2;
}
printf("%lld\n",rez);
}
int main()
{
freopen("medie.in","r",stdin);
freopen("medie.out","w",stdout);
read();
solve();
return 0;
}