#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ ll N, g, b, ans=0, cnt; cin >> N; vector r(N), cb(3e3+1), cg(3e3+1); for (int i=0; i> r[i]; for (int i=0; i> g; cg[g]++; } for (int i=0; i> b; cb[b]++; } for (int g=1; g<=3e3; g++){ for (int b=1; b<=3e3; b++){ cnt = lower_bound(r.begin(), r.end(), g+b)-lower_bound(r.begin(), r.end(), max(g, b)); ans += cnt * cg[g] * cb[b]; } } cout << ans << endl; return 0; }