Language: C++

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
using System.Text.RegularExpressions;
//byte 255 int<2147483647 ≒ 2 * 10^9 long < 9223372036854775807 ≒ 9 * 10^18
//decimal 29桁

class Myon
{
    //chokudaiさんのコードをコピペ
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        
        return 0;
    }

    public void calc()
    {
        int n = cin.nextInt();
        int[] l = cin.nextIntArr(n);

        Array.Sort(l);

        int ans = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            for (int j = i - 1; j >= 0; j--)
            {
                int condK = l[i] - l[j] + 1;
                int index = nibuntansaku(l, condK, j);
                int number = j - index;
                ans += number;
            }
        }

        ShowL(ans);

    }

    int nibuntansaku(int[] a, int s, int iLast)
    {
        //sが挿入されてソートされるaのindex
        int f = 0, l = iLast;
        int len = a.Length;
        int index = -1;

        while(l - f >= 1)
        {
            index = (f + l) / 2;
            if (a[index] == s) { f = index; break; }
            else if (a[index] > s) l = index;
            else f = index+1;
        }

        return f;
    }



    public static void Write<T>(string tag, IEnumerable<T> e)
    {
        Console.WriteLine(tag.PadRight(20) + string.Join(",", e));
    }
    public static void Write<T>(string tag, T e)
    {
        Console.WriteLine(tag.PadRight(20) + e);
    }

    #region utilities
    public static void ShowL() { Console.WriteLine(""); }
    public static void ShowL<T>(T s) { Console.WriteLine(s); }
    public static void Show<T>(T s) { Console.Write(s); }
    public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }

    #endregion utilities
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] nextIntArr(long n)
    {
        int[] output = new int[n];
        for (int i = 0; i < n; i++) output[i] = nextInt();
        return output;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}
static class SMath
{
    
    /// <summary>
    /// 素因数分解して、n番目に見つかった素因数をoutput[n-1]に返します。
    /// 12 なら 2,2,3 です。
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static List<long> Factorization(long n)
    {
        if (n <= 0) return null;
        List<long> output = new List<long>();
        int i = 2;
        long max = (long)Math.Sqrt(n); ;
        while (n > 1)
        {
            if (i > max) { output.Add(n); break; }
            while (n % i == 0)
            {
                output.Add(i);
                n /= i;
            }
            i++;
        }
        return output;
    }

    /// <summary>
    /// 素因数分解して、n番目に見つかった素因数をoutput[n-1]に返します。
    /// 84 = (2^2 * 3 * 7) なら 2, 1, 0, 1 　remainder = 1です。(打ち切られない）
    /// 13 = 0,0,...0 remainder = 2019
    /// ただし、試行を打ち切った時に限り残りをremainderに返す。(remainderは素数または1となる)
    /// </summary>
    /// <param name="n"></param>
    /// <param name="remainder"></param>
    /// <returns></returns>
    public static List<long> Factorization(long n, out long remainder)
    {
        //output[i] が i-1番目の素数の数を示す
        //ただし、試行を打ち切った時に限り残りをremainderに返す。(remainderは素数または1となる)
        remainder = 1;
        if (n <= 0) return null;
        List<long> output = new List<long>();
        long tempn = 2;
        long max = (long)Math.Sqrt(n);
        bool[] isNOTPrime = new bool[max+1];
        while (n > 1)
        {

            if (tempn > max) { remainder = n; break; }
            if (!isNOTPrime[tempn])
            {
                output.Add(0);
                while (n % tempn == 0)
                {
                    output[output.Count - 1]++;
                    n /= tempn;
                }
                for (long j = tempn * 2; j < isNOTPrime.Length; j += tempn) isNOTPrime[j] = true;
            }
            tempn++;
        }
        return output;
    }

    /// <summary>
    /// i番目の素数をoutput[i-1]に返します。
    /// ただしnより大きい素数については判定しません。
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static List<long> GetPrimeNumbers(long n)
    {
        if (n <= 0) return null;
        List<long> output = new List<long>();
        long tempn = 2;
        bool[] isNOTPrime = new bool[n + 1];
        while (n > 1)
        {
            if (tempn > n) { break; }
            if (!isNOTPrime[tempn])
            {
                output.Add(tempn);
                for (long j = tempn * 2; j < isNOTPrime.Length; j += tempn) isNOTPrime[j] = true;
            }
            tempn++;
        }
        return output;
    }


    private static long[][] combMemo;
    private static int maxn_combination = -1;
    public static long Combination(int n, int k)
    {
        if (n < 0 || k > n) return 0;
        if (n == k || k == 0) return 1;
        if (k > n/2) return Combination(n, n - k);
        if (maxn_combination < n)
        {
            maxn_combination = n;
            combMemo = new long[n+1][];
        }
        if (combMemo[n] == null) combMemo[n] = new long[n/2 + 1];
        if (combMemo[n][k] != 0) return combMemo[n][k];
        else
        {
            combMemo[n][k] = Combination(n - 1, k) + Combination(n - 1, k - 1);
            return combMemo[n][k];
        }
        
    }
    public static long Gcd(long a, long b)
    {
        if (a <= 0) return -1;
        //if (a > b) return gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
    public static long Lcm(long a,long b)
    {
        return a / Gcd(a, b) * b;
    }


    public class pairComparer : IComparer<int[]>
    {
        int index = 0;
        public pairComparer(int n)
        {
            index = n;
        }
        public pairComparer()
        {
            index = 0;
        }
        public int Compare(int[] x, int[] y)
        {
            return y[index] - y[index];
        }
    }

}

Compiler output:
a.cc:79:6: error: invalid preprocessing directive #region
   79 |     #region utilities
      |      ^~~~~~
a.cc:85:6: error: invalid preprocessing directive #endregion
   85 |     #endregion utilities
      |      ^~~~~~~~~
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.IO;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Linq;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
    6 | using System.Text;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'System'
    7 | using System.Globalization;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
    8 | using System.Numerics;
      |       ^~~~~~
a.cc:9:7: error: expected nested-name-specifier before 'System'
    9 | using System.Text.RegularExpressions;
      |       ^~~~~~
a.cc:16:12: error: 'Scanner' does not name a type
   16 |     static Scanner cin;
      |            ^~~~~~~
a.cc:17:11: error: expected ':' before 'Myon'
   17 |     public Myon() { }
      |           ^~~~~
      |           :
a.cc:18:11: error: expected ':' before 'static'
   18 |     public static int Main()
      |           ^~~~~~~
      |           :
a.cc:27:11: error: expected ':' before 'void'
   27 |     public void calc()
      |           ^~~~~
      |           :
a.cc:50:28: error: expected ',' or '...' before 'a'
   50 |     int nibuntansaku(int[] a, int s, int iLast)
      |                            ^
a.cc:70:11: error: expected ':' before 'static'
   70 |     public static void Write<T>(string tag, IEnumerable<T> e)
      |           ^~~~~~~
      |           :
a.cc:70:24: error: variable or field 'Write' declared void
   70 |     public static void Write<T>(string tag, IEnumerable<T> e)
      |                        ^~~~~
a.cc:70:24: error: expected ';' at end of member declaration
   70 |     public static void Write<T>(string tag, IEnumerable<T> e)
      |                        ^~~~~
      |                             ;
a.cc:70:29: error: expected unqualified-id before '<' token
   70 |     public static void Write<T>(string tag, IEnumerable<T> e)
      |                             ^
a.cc:74:11: error: expected ':' before 'static'
   74 |     public static void Write<T>(string tag, T e)
      |           ^~~~~~~
      |           :
a.cc:74:24: error: variable or field 'Write' declared void
   74 |     public static void Write<T>(string tag, T e)
      |                        ^~~~~
a.cc:74:24: error: expected ';' at end of member declaration
   74 |     public static void Write<T>(string tag, T e)
      |                        ^~~~~
      |                             ;
a.cc:74:29: error: expected unqualified-id before '<' token
   74 |     public static void Write<T>(string tag, T e)
      |                             ^
a.cc:80:11: error: expected ':' before 'static'
   80 |     public static void ShowL() { Console.WriteLine(""); }
      |           ^~~~~~~
      |           :
a.cc:81:11: error: expected ':' before 'static'
   81 |     public static void ShowL<T>(T s) { Console.WriteLine(s); }
      |           ^~~~~~~
      |           :
a.cc:81:24: error: variable or field 'ShowL' declared void
   81 |     public static void ShowL<T>(T s) { Console.WriteLine(s); }
      |                        ^~~~~
a.cc:81:24: error: expected ';' at end of member declaration
   81 |     public static void ShowL<T>(T s) { Console.WriteLine(s); }
      |                        ^~~~~
      |                             ;
a.cc:81:29: error: expected unqualified-id before '<' token
   81 |     public static void ShowL<T>(T s) { Console.WriteLine(s); }
      |                             ^
a.cc:82:11: error: expected ':' before 'static'
   82 |     public static void Show<T>(T s) { Console.Write(s); }
      |           ^~~~~~~
      |           :
a.cc:82:24: error: variable or field 'Show' declared void
   82 |     public static void Show<T>(T s) { Console.Write(s); }
      |                        ^~~~
a.cc:82:24: error: expected ';' at end of member declaration
   82 |     public static void Show<T>(T s) { Console.Write(s); }
      |                        ^~~~
      |                            ;
a.cc:82:28: error: expected unqualified-id before '<' token
   82 |     public static void Show<T>(T s) { Console.Write(s); }
      |                            ^
a.cc:83:11: error: expected ':' before 'static'
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |           ^~~~~~~
      |           :
a.cc:83:39: error: 'string' has not been declared
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                       ^~~~~~
a.cc:83:59: error: 'string' has not been declared
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                                           ^~~~~~
a.cc:86:2: error: expected ';' after class definition
   86 | }
      |  ^
      |  ;
a.cc:83:53: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                                     ^~~~~
      |                                                     |
      |                                                     const char*
a.cc:83:75: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                                                           ^~~~
      |                                                                           |
      |                                                                           const char*
a.cc: In static member function 'static int Myon::Main()':
a.cc:21:9: error: 'cin' was not declared in this scope
   21 |         cin = new Scanner();
      |         ^~~
a.cc:21:19: error: expected type-specifier before 'Scanner'
   21 |         cin = new Scanner();
      |                   ^~~~~~~
a.cc:22:19: error: expected ';' before '.' token
   22 |         new Myon().calc();
      |                   ^
a.cc: In member function 'void Myon::calc()':
a.cc:29:17: error: 'cin' was not declared in this scope
   29 |         int n = cin.nextInt();
      |                 ^~~
a.cc:30:12: error: structured binding declaration cannot have type 'int'
   30 |         int[] l = cin.nextIntArr(n);
      |            ^~
a.cc:30:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:30:12: error: empty structured binding declaration
a.cc:30:15: error: expected initializer before 'l'
   30 |         int[] l = cin.nextIntArr(n);
      |               ^
a.cc:32:9: error: 'Array' was not declared in this scope
   32 |         Array.Sort(l);
      |         ^~~~~
a.cc:32:20: error: 'l' was not declared in this scope
   32 |         Array.Sort(l);
      |                    ^
a.cc:46:14: error: no matching function for call to 'Myon::ShowL(int&)'
   46 |         ShowL(ans);
      |         ~~~~~^~~~~
a.cc:80:24: note: candidate: 'static void Myon::ShowL()'
   80 |     public static void ShowL() { Console.WriteLine(""); }
      |                        ^~~~~
a.cc:80:24: note:   candidate expects 0 arguments, 1 provided
a.cc: In member function 'int Myon::nibuntansaku(int*)':
a.cc:53:24: error: 'iLast' was not declared in this scope
   53 |         int f = 0, l = iLast;
      |                        ^~~~~
a.cc:54:19: error: 'a' was not declared in this scope
   54 |         int len = a.Length;
      |                   ^
a.cc:60:29: error: 's' was not declared in this scope
   60 |             if (a[index] == s) { f = index; break; }
      |                             ^
a.cc: In static member function 'static void Myon::ShowL()':
a.cc:80:34: error: 'Console' was not declared in this scope
   80 |     public static void ShowL() { Console.WriteLine(""); }
      |                                  ^~~~~~~
a.cc: In static member function 'static void Myon::Yorn(bool, int, int)':
a.cc:83:98: error: no matching function for call to 'Myon::ShowL(int&)'
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                                                                             ~~~~~^~~~~~
a.cc:80:24: note: candidate: 'static void Myon::ShowL()'
   80 |     public static void ShowL() { Console.WriteLine(""); }
      |                        ^~~~~
a.cc:80:24: note:   candidate expects 0 arguments, 1 provided
a.cc:83:116: error: no matching function for call to 'Myon::ShowL(int&)'
   83 |     public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); }
      |                                                                                                               ~~~~~^~~~~~~~~
a.cc:80:24: note: candidate: 'static void Myon::ShowL()'
   80 |     public static void ShowL() { Console.WriteLine(""); }
      |                        ^~~~~
a.cc:80:24: note:   candidate expects 0 arguments, 1 provided
a.cc: At global scope:
a.cc:89:1: error: expected class-name before '{' token
   89 | {
      | ^
a.cc:90:11: error: expected ':' before 'override'
   90 |     public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
      |           ^~~~~