/*#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int n,d, i, j,p[36000], c, l, a, b, m ,maxi, nr, v[1000];
ifstream fin("rachete.in");
ofstream fout("rachete.out");
string s;
int main()
{
fin >> n >> m ;
for ( i = 2; i <= 35000 ; ++i)
{
if (!p[i])
{
for (j = i + i; j <= n; j += i)
p[j] = 1;
}
}
for (a = 1; a <= n * m ; ++a)
{
fin >> v[a];
if (p [a] == 0)
v[a] = 0;
else if (a - v[a] > maxi)
{
maxi = a - v[a];
++nr;
}
else v[a] = 0;
}
fout << maxi << " " << nr + 1;
for (b = 1; b <= n * m; ++b)
{
if (!(v[b]))
fout << v[b];
}
return 0;
}
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int n,d, i, j,p[36000],k[36000], c, l, a, b, m[100][100] ,maxi, nr, v[1000];
ifstream fin("rachete.in");
ofstream fout("rachete.out");
string s;
int main()
{
for ( i = 2; a <= 35000 ; ++i)
{
if (!p[i])
{
for (j = i + i; j <= n; j += i)
p[j] = 1;
}
if (p[i] == 0)
k[i] = p[i];
}
for (i = 1; i <= n; ++i)
for (j = 1; j <= n; ++j)
{
fin >> m[i][j];
if (p[m[i][j]] == 0)
m[i][j] = 0;
else if (k[i] - m[i][j] > maxi)
{
maxi = k[i] - m[i][j];
++nr;
}
}
fout << maxi << " " << nr + 1;
for (i = 1; i <= n; ++i)
{
if (m[i][j] + maxi == k[i])
fout << m[i][j];
}
return 0;
}
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int n, i, k, h, p, d, a, maxi, nr, r, v[1100], e[1100], g[1100];
ifstream fin("scara.in");
ofstream fout("scara.out");
string s;
int main()
{
fin >> k >> h;
for (i = 1; i <= h; ++i)
{
fin >> v[i];
if (v[i] > maxi)
maxi = v[i];
}
while (nr < k)
{
for (i = 2; i <= 1000; ++i)
{
for (d = 2; d * d <= i; d++)
{
if (i % d != 0 && v[i] != a)
g[i] = i;
++nr;
}
}
}
for (i = 1; i <= nr; ++i)
fout << g[i];
return 0;
}
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int n, a, nr, j, i, b, m, g[1000], v[1000], maxi, mini;
ifstream fin("matrixdel.in");
ofstream fout("matrixdel.out");
string s;
int main()
{
fin >> n >> m;
maxi = 0;
mini = 50000;
for ( i = 1; i <= n; ++i)
fin >> v[i];
for ( i = n; i <= n + m; ++i)
fin >> g[i];
if (n > m)
for ( i = 1; i <= n + m; ++i)
{
if (v[i] == g[i] && v[i] > maxi)
maxi = v[i];
if (v[i] == g[i] && v[i] < mini)
mini = v[i];
}
else for ( i = 1; i <= m + n; ++i)
{
if (v[i] == g[i] && v[i] > maxi)
maxi = v[i];
if (v[i] == g[i] && v[i] < mini)
mini = v[i];
}
for (i = 1; i <= n; ++i)
{
if (v[i] < mini)
a += v[i];
if (v[i] > maxi)
a += v[i];
}
for (i = 1; i <= m; ++ i)
{
if (g[i] < mini)
b += g[i];
if (g[i] > maxi)
b += g[i];
}
fout << mini << " " << maxi << " ";
if (a > b)
fout << 1;
else if (a == b)
fout << 0;
else fout << 2;
return 0;
}
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int n, cod, a, b, c, d, nr, i;
ifstream fin("matrixdel.in");
ofstream fout("matrixdel.out");
string s;
int main()
{
fin >> n;
for (i = 1; i <= n; ++i)
{
nr = 0;
fin >> cod;
a = cod;
b = 10;
d = cod % 10;
while ( cod != 0)
{
c = cod % 10;
cod /= 10;
++nr;
}
while (b <= a)
b *= 10;
if (nr % 2 == 1)
{
if ( c < d )
fout << (a - d)/ (b/10) + c << " ";
else fout << a << " ";
}
else fout << a << " ";
}
return 0;
}
*/
/*
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
using namespace std;
int i, n, maxi,nr, s, suma, m, v[1000], g[1000];
ifstream fin("psp.in");
ofstream fout("psp.out");
int main()
{
fin >> n;
fin >> v[1];
for( i = 2;i <= n; ++i )
{
fin >> v[i];
}
s = 1;
for ( i =1; i < n; ++i)
{
s = 0;
if (v[i+1] < v[i])
{
m = v[i + 1];
v[i + 1] = v[i];
v[i] = m;
s = 1;
}
if ( s == 0 ) break;
}
for ( i = 1; i <= n; ++i )
{
fin >> g[i];
}
s = 1;
for ( i =1; i <= n; ++i)
{
s = 0;
if (v[i+1] > v[i])
{
m = v[i];
v[i] = v[i-1];
s = 1;
}
if ( s == 0 ) break;
}
}
suma = v[1] + g[1];
maxi = v[n] + g[1];
fout << suma << '\n';
fout << maxi << '\n';
for (i = 1; i <= n ; ++i)
{
if ( v[n - i - 1] + g[i] == maxi )
++ nr;
}
fout << nr;
return 0;
}
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#define F(i,j,n) for((i)=(j);(i<=(n));++(i))
using namespace std;
int i, n, k, nr, v[1000], g[1000] , j;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int main()
{
fin >> n;
for( i = 1; i <= n; ++i )
fin >> v[i];
sort(v + 1, v + n + 1);
for( i = 1; i <= n; ++i )
for( j = i + 1; j <= n; ++j )
for( k = j + 1; k <= n; ++k )
if (v[i] + v[j] >= v[k] && v[i] + v[k] >= v[j] && v[j] + v[k] >= v[i])
++nr;
fout << nr;
return 0;
}