import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None

if __name__ == '__main__':
    main() import math math import queue queue import bisect bisect from collections import deque,defaultdict import heapq as hpq heapq from sys import stdin,setrecursionlimit ipt = stdin.readline ipt stdin.readline stdin readline setrecursionlimit(10**7) setrecursionlimit 10**7 10 7 def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None main n = int(ipt()) n int(ipt()) int ipt() ipt int(i) for i in ipt().split() for i in ipt().split() i ipt().split() ().split () ipt split for i in ipt().split() int(i) int i l = [int(i) for i in ipt().split()] l [int(i) for i in ipt().split()] l.sort() l.sort l sort ans = 0 ans 0 [0]*(2*10**3+1) for i in range(2) for i in range(2) i range(2) range 2 for i in range(2) [0]*(2*10**3+1) [0] 0 2*10**3+1 2*10**3 2 10**3 10 3 1 dp = [[0]*(2*10**3+1) for i in range(2)] dp [[0]*(2*10**3+1) for i in range(2)] for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
     i l ans += sum(dp[1][i+1::]) ans sum(dp[1][i+1::]) sum dp[1][i+1::] [1] dp 1 i+1:: i+1 i 1 for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
         j range(i,2*10**3+1) range i 2*10**3+1 2*10**3 2 10**3 10 3 1 dp[1][j] += dp[0][j-i] dp[1][j] [1] dp 1 j dp[0][j-i] [0] dp 0 j-i j i dp[0][i] += 1 dp[0][i] [0] dp 0 i 1 print(ans) print ans return None None if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main ipt = stdin.readline stdin.readline ipt def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None main
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None

if __name__ == '__main__':
    main()
