1312 {
1313 unsigned int count = 0;
1314 unsigned short n;
1315 cin >> n;
1316 auto cows = vector<unsigned int>();
1317 cows.resize(n);
1318 for(int i = 0; i < n; i++) {
1319 unsigned int cow;
1320 cin >> cow;
1321 cows[i] = cow;
1322 }
1323 sort(cows.begin(), cows.end());
1324 for(auto i = cows.begin(); i != cows.end(); ++i) {
1325 for(auto j = i + 1; j != cows.end(); ++j) {
1326 const unsigned int xy = *j - *i;
1327 auto min = lower_bound(j, cows.end(), *j + xy);
1328 auto max = upper_bound(j, cows.end(), *j + 2 * xy);
1329 count += max - min;
1330 }
1331 }
1332 cout << count;
1333 return 0;
1334 }