The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.

Here $|z|$ denotes the absolute value of $z$.

Now, Jose is stuck on a question of his history exam: "What are the values of $x$ and $y$?" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$)  — the number of choices.

The second line contains $n$ pairwise distinct integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9$) — the choices Jose is considering.


-----Output-----

Print a single integer number — the number of unordered pairs $\{x, y\}$ formed by different numbers from Jose's choices that could make the legend true.


-----Examples-----
Input
3
2 5 -3

Output
2

Input
2
3 6

Output
1



-----Note-----

Consider the first sample. For the pair $\{2, 5\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:

 [Image] 

The legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\{5, -3\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:

 [Image] 

As Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\{2, -3\}$, for a total of two pairs.

In the second sample, the only pair is $\{3, 6\}$, and the situation looks as follows:

 [Image] 

Note that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Amortized analysis


Solutions:
from sys import stdin
from bisect import bisect
n = int(input())
l = list(map(int, stdin.readline().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
ans = 0
for i in range(n):
	a = bisect(l, 2 * l[i])
	ans += a - i - 1
print(ans)


import sys
input = sys.stdin.readline
from bisect import bisect_right, bisect_left
from collections import defaultdict
eps = 0.01

def get_count(a, l, r):
	return bisect_right(a, r) - bisect_left(a, l)

class Problem:

	def __init__(self):
		pass

	def solve(self):
		print(self._solve())

	def _solve(self):
		n = int(input())
		a = [int(item) for item in input().split()]
		ans = 0
		d = defaultdict(int)
		for x in a:
			d[x] += 1
		a = sorted(set(list(a)))
		n = len(a)
		for i in range(n):
			x = a[i]
			if x < 0:
				ans += get_count(a, -x / 2, -2 * x) + get_count(a, x, x / 2) - 1
			else:
				ans += get_count(a, x, 2 * x) - 1
		for x in d:
			ans += d[x] * (d[x] - 1) // 2
		return ans

def main():
	problem = Problem()
	problem.solve()
main()


import bisect
n = int(input())
z = sorted([abs(int(i)) for i in input().split()])
sum = 0
for i in range(n):
	tmp = bisect.bisect(z, z[i] * 2)
	if tmp > i:
		sum = sum + (tmp - i - 1)
print(sum)


import math

def read_task():
	n = int(input())
	task = [abs(int(x)) for x in input().split()]
	return task

def resolve(task):
	a = sorted(task)
	a.append(float('+inf'))
	count = 0
	j = 0
	for i in range(len(a) - 2):
		while a[j + 1] <= 2 * a[i]:
			j += 1
		if j > i:
			count += j - i
	return count

def print_solution(solution):
	print(solution)

def main():
	task = read_task()
	solution = resolve(task)
	print_solution(solution)
main()


n = int(input())
a = list(map(int, input().split()))
from bisect import bisect_right as br
for i in range(n):
	a[i] = abs(a[i])
a.sort()
ans = 0
for i in range(n):
	j = br(a, 2 * a[i]) - 1
	ans += j - i
print(ans)


import sys
try:
	sys.stdin = open('in.in', 'r')
except:
	pass
n = int(input())
a = list(map(lambda x: abs(int(x)), input().split()))
a.sort()
l = 0
ans = 0
for r in range(n):
	while l < r and a[l] * 2 < a[r]:
		l += 1
	ans += r - l
print(ans)


n = int(input())
a = sorted(map(abs, map(int, input().split())))
j = ans = 0
for i in range(n):
	while 2 * a[j] < a[i]:
		j += 1
	ans += i - j
print(ans)


n = int(input())
nums = (abs(int(x)) for x in input().split())
nums = list(sorted(nums))
left = 0
right = 0
ans = 0
while left < n:
	while right < n and nums[right] <= 2 * nums[left]:
		right += 1
	ans += right - left - 1
	left += 1
print(ans)


n = int(input())
a = sorted([int(q) for q in input().split()], key=lambda x: (abs(x), x))
ans = q1 = q2 = 0
for q in range(len(a)):
	while len(a) > q2 and a[q2] == a[q]:
		q2 += 1
	while len(a) > q1 and abs(a[q1]) <= 2 * abs(a[q]):
		q1 += 1
	ans += q1 - q2
print(ans)


n = int(input())
A = list(map(int, input().split()))
for i in range(n):
	if A[i] < 0:
		A[i] = abs(A[i])
ans = 0
i = 0
j = 1
A.sort()
while i < n and j < n:
	if A[j] <= 2 * A[i]:
		j += 1
	else:
		ans += j - i - 1
		i += 1
		if i == j:
			j += 1
ans += (j - i - 1) * (j - i) // 2
print(ans)


n = int(input())
a = sorted(map(abs, map(int, input().split())))
r = i = j = 0
while i < n:
	while 2 * a[j] < a[i]:
		j += 1
	r += i - j
	i += 1
print(r)


from sys import *
from math import *
from bisect import *
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
for i in range(n):
	if a[i] < 0:
		a[i] = -a[i]
a.sort()
ans = 0
for i in range(n):
	x = bisect_right(a, 2 * a[i])
	ans += x - i - 1
print(ans)


import math
import re
import sys
from collections import defaultdict
from heapq import heappush, heappop
from fractions import gcd

def read(type=int):
	return type(input())

def read_list(type=int, split=' ', F=None):
	if F:
		return map(lambda x: F(type(x)), raw_input().split(split))
	return map(type, input().split(split))

def read_list_of_list(N, type=int, split=' ', F=None):
	return [read_list(type, F=F) for _ in range(N)]
n = read()
A = read_list()
A = list(sorted(map(abs, A)))
i = j = R = 0
while i < n:
	while j < n and A[j] - A[i] <= A[i]:
		j += 1
	R += j - 1 - i
	i += 1
print(R)


import bisect

def main():
	n = int(input())
	pts = list(map(int, input().split()))
	points = []
	for i in range(n):
		points.append(abs(pts[i]))
	points.sort()
	pairs = 0
	for i in range(n):
		x = points[i]
		index = bisect.bisect(points, 2 * x) - 1
		if points[index] <= 2 * x:
			if index >= i:
				pairs += index - i
	print(pairs)
main()


n = int(input())
l = [abs(int(x)) for x in input().split()]
l = sorted(l)
ans = 0
left = 0
for right in range(n):
	while left < right and l[right] > 2 * l[left]:
		left += 1
	ans += right - left
print(ans)


import bisect
n = int(input())
l = [abs(int(x)) for x in input().split()]
l.sort()
res = 0
for i in range(n - 1):
	b = bisect.bisect_right(l, 2 * l[i], i + 1)
	res += b - i - 1
print(res)


import bisect
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
for i in range(n):
	arr[i] = abs(arr[i])
arr.sort()
ans = 0
for i in range(n):
	temp = bisect.bisect_right(arr, 2 * arr[i], i)
	ans += max(0, temp - i - 1)
print(ans)


def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
from bisect import bisect_right
n = getN()
nums = [abs(i) for i in getList()]
nums.sort(reverse=False)
ans = 0
for (i, num) in enumerate(nums):
	ans += bisect_right(nums, num * 2) - i - 1
print(ans)


import sys
n = int(input())
a = [abs(int(x)) for x in input().split()]
a.sort()
(rt, rez) = (n - 1, 0)
for i in range(n - 1, -1, -1):
	lim = (a[i] + 1) // 2
	while rt >= 0 and a[rt] >= lim:
		rt -= 1
	rez += i - rt - 1
print(rez)


def lower(a, t):
	l = 0
	r = len(a) - 1
	ans = 0
	while r - l >= 0:
		mid = (l + r) // 2
		if abs(a[mid]) < t:
			l = mid + 1
		if abs(a[mid]) >= t:
			r = mid - 1
			ans = mid
	return ans

def upper(a, t):
	l = 0
	r = len(a) - 1
	ans = 0
	while r - l >= 0:
		mid = (l + r) // 2
		if abs(a[mid]) <= t:
			l = mid + 1
			ans = mid
		if abs(a[mid]) > t:
			r = mid - 1
	return ans
n = int(input())
a = list(map(int, input().split()))
a.sort(key=abs)
ct = 0
for i in a:
	ct += upper(a, abs(i) * 2) - lower(a, abs(i) / 2)
print(ct // 2)


n = int(input())
A = [abs(int(i)) for i in input().split()]
A.sort()
ans = 0

def b_search(ok, ng, comp):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if comp(mid):
			ok = mid
		else:
			ng = mid
	return ok
prev = -1
for a in A:
	if prev == a:
		ans -= 1
	prev = a
	left = b_search(n, -1, lambda x: A[x] >= a)
	right = b_search(-1, n, lambda x: A[x] <= 2 * a)
	ans += max(0, right - left)
print(ans)


from bisect import bisect_right
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(lambda x: abs(int(x)), input().split()))
A.sort()
ans = 0
for i in range(N):
	ib = bisect_right(A, A[i] * 2)
	ans += ib - i - 1
print(ans)


n = int(input())
a = [abs(int(x)) for x in input().split()]
a.sort()
count = 0
l = 0
r = 0
while l < n:
	while r < n and 2 * a[l] >= a[r]:
		r += 1
	count += r - l - 1
	l += 1
print(count)


def main():
	n = int(input())
	a = sorted(map(abs, list(map(int, input().split()))))
	i = 0
	res = 0
	for j in range(n):
		while a[i] * 2 < a[j]:
			i += 1
		res += j - i
	print(res)
main()


n = int(input())
l = sorted([abs(int(i)) for i in input().split()])
ans = 0
(i, j) = (0, 0)
while i < n:
	while j < n and l[i] + l[i] >= l[j]:
		j += 1
	ans += j - i - 1
	i += 1
print(ans)


n = int(input())
a = sorted([int(x) for x in input().split()])
counter = 0
answer = 0
end = 1
for i in range(n):
	if a[i] < 0:
		a[i] = a[i] * -1
a.sort()
for i in range(n):
	end = max(end, i + 1)
	for j in range(end, n):
		if a[i] * 2 < a[j]:
			end = j
			break
		else:
			counter += 1
	else:
		end = j + 1
	answer += counter
	counter = max(counter - 1, 0)
print(answer)


import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
arr.sort()

def binarySearch(l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if arr[mid] > x and arr[mid - 1] <= x:
			return mid
		elif arr[mid] > x:
			return binarySearch(l, mid - 1, x)
		else:
			return binarySearch(mid + 1, r, x)
	else:
		return -1

def mod(l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if arr[mid] >= x and arr[mid - 1] < x:
			return mid
		elif arr[mid] > x:
			return mod(l, mid - 1, x)
		else:
			return mod(mid + 1, r, x)
	else:
		return -1
count = 0
for i in range(n):
	count += n
	count -= i + 1
	if arr[i] < 0:
		bs1 = binarySearch(0, n - 1, 2 * abs(arr[i]))
		if bs1 >= 0:
			count -= n - bs1
		bs2 = binarySearch(0, n - 1, -abs(arr[i] / 2))
		if bs2 >= 0:
			count -= n - bs2
		bs3 = mod(0, n - 1, abs(arr[i] / 2))
		if bs3 >= 0:
			count += n - bs3
	else:
		bs = binarySearch(0, n - 1, 2 * arr[i])
		if bs >= 0:
			count -= n - bs
print(count)


n = int(input())
l = sorted((abs(int(a)) for a in input().split()))
j = 0
answer = 0
for (i, a) in enumerate(l):
	while j < n - 1 and l[j + 1] <= a << 1:
		j += 1
	answer += j - i
print(answer)


def fun(n):
	return abs(int(n))
n = int(input())
seq = sorted(map(fun, input().split()))
ans = 0
tmp = 0
le = 0
ri = le + 1
while le < n:
	while ri < n and seq[ri] <= seq[le] * 2:
		ri += 1
		tmp += 1
	ans += tmp
	if tmp > 0:
		tmp -= 1
	le += 1
	if le == ri:
		ri += 1
print(ans)


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from itertools import permutations, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	n = fi()
	a = li()
	for i in range(n):
		a[i] = abs(a[i])
	a.sort()
	c = 0
	for i in range(n):
		c += i - bisect_left(a, a[i] / 2)
	print(c)


from bisect import bisect_left as bl
from bisect import bisect_right as br
n = int(input())
arr = list(map(lambda x: abs(int(x)), input().split()))
arr.sort()
total = 0
for (i, e) in enumerate(arr):
	total += max(br(arr, e * 2) - i - 1, 0)
print(total)


import bisect
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = abs(a[i])
a.sort()
res = 0
ae = enumerate(a, start=0)
for (i, j) in ae:
	r = bisect.bisect(a, 2 * j)
	res += r - i - 1
print(res)


from bisect import bisect_right
n = int(input())
A = list(map(int, input().split()))
for i in range(len(A)):
	A[i] = abs(A[i])
A.sort()
cnt = 0
for i in range(len(A)):
	q = 2 * A[i]
	j = bisect_right(A, q)
	cnt += max(0, j - i - 1)
print(cnt)


n = int(input())
a = list(map(lambda x: abs(int(x)), input().split()))
a.sort()
l = 0
ans = 0
for r in range(n):
	while l < r and a[l] * 2 < a[r]:
		l += 1
	ans += r - l
print(ans)


N = int(input())
List = sorted([abs(int(i)) for i in input().split()])
l = len(List) - 2
r = len(List) - 1
answer = 0
while l > -1:
	while 2 * List[l] >= List[r] and l > -1:
		l -= 1
	if l >= 0:
		answer += r - 1 - l
		r -= 1
	if l == -1:
		answer += r * (r + 1) / 2
		break
print(int(answer))


import math

def solve(n):
	L = list(map(int, input().split()))
	res = 0
	for i in range(n):
		L[i] = abs(L[i])
	L.sort()
	r = 1
	for i in range(n - 1):
		while r < n and L[r] <= L[i] * 2:
			r += 1
		res += r - i - 1
	return res
	print(L)
	return L
k = int(input())
print(solve(k))


n = int(input())
a = sorted(list(map(lambda x: abs(int(x)), input().split())))
ret = 0
for i in range(n - 1):
	left = i
	right = n
	while right > left + 1:
		mid = (left + right) // 2
		if a[mid] - a[i] <= a[i]:
			left = mid
		else:
			right = mid
	ret += left - i
print(ret)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	n = ii()
	a = li()
	(pos, neg) = ([], [])
	for i in range(n):
		if a[i] < 0:
			a[i] = abs(a[i])
	ans = 0
	a.sort()
	for i in range(n):
		x = 2 * a[i]
		l = i + 1
		r = n - 1
		p = -1
		while l <= r:
			m = l + (r - l) // 2
			if a[m] <= x:
				l = m + 1
				p = m
			else:
				r = m - 1
		if p == -1:
			continue
		ans += p - i
	print(ans)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		k = self.next_int()
		x = sorted((abs(x) for x in self.next_ints()))
		i = 0
		r = 0
		for j in range(k):
			while x[j] - x[i] > x[i]:
				i += 1
			r += j - i
		print(r)
Main().solve()


import sys
from collections import Counter
from bisect import bisect_right as br

def numofpairs(n):
	return n * (n - 1) // 2
n = int(sys.stdin.readline().strip())
ints = list(map(lambda x: abs(int(x)), sys.stdin.readline().split()))
ints.sort()
counter = 0
for (index, val) in enumerate(ints[:-1]):
	upperindex = br(ints, 2 * val) - 1
	indexspan = upperindex - index
	counter += indexspan
print(counter)


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = sorted(map(lambda x: abs(int(x)), stdin.readline().split()))
	ans = 0
	for i in range(n):
		l = i
		r = n - 1
		while l <= r:
			mid = l + r >> 1
			if a[mid] > 2 * a[i]:
				r = mid - 1
			else:
				l = mid + 1
		ans += r - i
	print(ans)


from bisect import bisect
(n, a) = (int(input()), [*map(int, input().split())])
b = sorted((abs(x) for x in a))
print(sum((bisect(b, 2 * x, i) - i - 1 for (i, x) in enumerate(b))))


N = int(input())
arr = input()
arr = [int(x) for x in arr.split(' ')]
arr = sorted(arr, key=abs)
idx1 = 0
idx2 = 1
ans = 0
while idx1 < N or idx2 < N:
	if idx2 == N:
		ans += idx2 - 1 - idx1
		idx1 += 1
	elif abs(arr[idx1]) * 2 < abs(arr[idx2]):
		ans += idx2 - 1 - idx1
		idx1 += 1
	elif abs(arr[idx1]) * 2 >= abs(arr[idx2]):
		idx2 += 1
print(ans)


import bisect
n = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
	if a[i] < 0:
		a[i] = -a[i]
a.sort()
count = 0
for i in range(1, len(a)):
	ind = bisect.bisect_left(a, a[i] / 2, 0, i)
	if ind < i:
		count += i - ind
print(count)


n = int(input())
x = [abs(int(w)) for w in input().split()]
x = sorted(x)
ans = 0
j = 0
for i in range(n):
	while 2 * x[j] < x[i]:
		j += 1
	ans += i - j
print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
points = sorted([abs(int(i)) for i in input().split()])
ans = 0
for i in range(n):
	pos = bisect_right(points, 2 * points[i])
	ans += pos - i - 1
print(ans)


import sys
from bisect import bisect_right
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
T = 1
while T:
	T -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a = [abs(x) for x in a]
	ans = 0
	a.sort()
	for i in range(n):
		ans += bisect_right(a, 2 * a[i]) - i - 1
	print(ans)


import bisect
n = int(input())
list1 = list(map(int, input().split()))
for i in range(n):
	list1[i] = abs(list1[i])
list1.sort()
ans = 0
for i in range(n):
	p = bisect.bisect_right(list1, 2 * list1[i]) - i - 1
	ans += p
print(ans)


import itertools
import bisect
n = int(input())
arr = sorted(list(map(lambda x: abs(int(x)), input().strip().split())))
answer = 0
for i in range(n):
	answer += bisect.bisect_right(arr, arr[i] * 2) - 1 - i
print(answer)


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
from bisect import bisect
n = iin()
a = lin()
for i in range(n):
	if a[i] < 0:
		a[i] *= -1
a.sort()
sol = 0
i = 0
while i < n:
	x = a[i]
	r = bisect(a, x + x)
	if r >= n or a[r] != 2 * x:
		r -= 1
	sol += r - i
	i += 1
print(sol)


import bisect
n = int(input())
li = list(map(int, input().split()))
for i in range(n):
	if li[i] < 0:
		li[i] = -li[i]
li.sort()
ans = 0
for (i, j) in enumerate(li[:-1]):
	t = bisect.bisect(li, 2 * j)
	ans = ans + (t - i - 1)
print(ans)


def bs(a, right, x):
	(l, r) = (-1, right)
	while r - l > 1:
		m = l + (r - l) // 2
		if x <= 2 * a[m]:
			r = m
		else:
			l = m
	return r
n = int(input())
a = list(map(abs, map(int, input().split())))
a.sort()
ans = 0
for (i, elem) in enumerate(a):
	pos = bs(a, i, elem)
	ans += i - pos
print(ans)


n = int(input())
A = list(map(int, input().split()))
A = [abs(a) for a in A]
A.sort()
j = 0
ANS = 0
for i in range(n - 1):
	while j < n - 1 and A[j + 1] - A[i] <= A[i]:
		j += 1
	ANS += j - i
print(ANS)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
a = sorted(list((abs(int(x)) for x in input().split())))
l = 0
r = 1
ans = 0
while l < n:
	while r < n and 2 * a[l] >= a[r]:
		r += 1
	ans += r - l - 1
	l += 1
print(ans)


from bisect import bisect_left, bisect_right

def answer(n, A):
	A.sort()
	count = 0
	for i in range(1, n):
		if A[i] <= 0:
			index = bisect_left(A, 2 * A[i])
			count += i - index
		else:
			index1 = bisect_left(A, -2 * A[i])
			index2 = bisect_right(A, -1 * ((A[i] + 1) // 2))
			index3 = bisect_left(A, (A[i] + 1) // 2)
			count += index2 - index1 + i - index3
	return count
n = int(input())
arr = list(map(int, input().split()))
print(answer(n, arr))


import bisect
n = int(input())
arr = []
l = input().split()
li = [int(i) for i in l]
for i in li:
	arr.append(abs(i))
arr.sort()
ans = 0
for i in range(n):
	ans += bisect.bisect_right(arr, 2 * arr[i]) - (i + 1)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	if l[i] < 0:
		l[i] *= -1
l.sort()
st = 0
end = 1
ans = 0
while end < n:
	if l[end] <= 2 * l[st]:
		ans += end - st
		end += 1
	else:
		st += 1
	if end == st:
		end += 1
print(ans)


import sys, heapq, bisect
from collections import deque, defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
DBG = True and False

def ddprint(x):
	if DBG:
		print(x)
n = inn()
a = inl()
a.sort()
ddprint(a)
sum = 0
for i in range(n - 1):
	ai = a[i]
	if ai < 0:
		p1 = bisect.bisect_right(a, ai // 2)
		p2 = bisect.bisect_left(a, (-ai + 1) // 2)
		p3 = bisect.bisect_right(a, -ai * 2)
		ddprint('i {} ai {} p123 {} {} {}'.format(i, ai, p1, p2, p3))
		sum += p1 - i - 1 + (p3 - p2)
	elif ai > 0:
		p5 = bisect.bisect_right(a, ai * 2)
		ddprint('i {} ai {} p45 {} {}'.format(i, ai, i, p5))
		sum += p5 - i - 1
print(sum)


from bisect import bisect_left
n = int(input())

def process():
	result = 0
	tmp = 0
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] = abs(a[i])
	a.sort()
	for i in range(n):
		x = a[i] // 2
		if a[i] % 2 == 1:
			x += 1
		tmp = bisect_left(a, x)
		if a[tmp] < x:
			continue
		result += i - tmp
	print(result)
process()


from bisect import bisect
n = int(input())
a = [abs(int(i)) for i in input().split(' ')]
b = sorted(a)
c = 0
for l in range(n):
	r = bisect(b, 2 * b[l])
	c += r - l - 1
print(c)


def main():
	import sys
	input = sys.stdin.readline

	def va(x):
		return abs(int(x))
	n = int(input())
	points = list(map(va, input().split()))
	points.sort()

	def dichotomie(fin, valeur, debut):
		a = 0
		b = fin
		while b - a > 1:
			c = (a + b) // 2
			if points[c] >= valeur:
				b = c
			else:
				a = c
		if points[a] >= valeur:
			return a
		else:
			return b
	somme = 0
	a = 0
	for i in range(len(points)):
		valeur = points[i]
		a = dichotomie(i, valeur / 2, a)
		somme += i - a
	print(somme)
main()


import bisect
n = int(input())
a = list(map(int, input().split()))
a = [abs(i) for i in a]
a.sort()
c = 0
for i in range(len(a) - 1):
	ind = bisect.bisect_right(a, 2 * a[i], i, len(a))
	c += ind - i
	if ind >= len(a) or a[ind] != 2 * a[i]:
		c -= 1
print(c)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = ria()
		for i in range(n):
			a[i] = abs(a[i])
		ans = 0
		a = sorted(a)
		for i in range(n):
			ans += i - bisect.bisect_left(a, math.ceil(a[i] / 2))
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
s = 0
for i in range(n - 1):
	j = n - 1
	v = l[i] * 2
	co = i
	cin = -2
	pin = -1
	while cin != pin:
		pin = cin
		cin = (i + j) // 2
		if l[cin] > v:
			j = cin
		else:
			i = cin
	if l[cin + 1] <= v:
		cin += 1
	s += cin - co
print(s)


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
l = list(map(int, input().split()))
l = [abs(i) for i in l]
l.sort()
c = 0
for i in range(n):
	j = bisect_right(l, 2 * l[i])
	c += j - 1 - i
print(c)


from bisect import bisect_left
n = int(input())
a = sorted(map(abs, map(int, input().split())))
r = 0
for (i, v) in enumerate(a):
	t = bisect_left(a, (v + 1) // 2)
	r += i - t
print(r)


n = int(input())
l1 = list(map(int, input().split()))
l2 = []
for i in range(0, n):
	if l1[i] != 0:
		l2.append(abs(l1[i]))
import bisect
l2.sort()
ans = 0
for i in range(0, len(l2)):
	x = bisect.bisect_right(l2, 2 * l2[i], 0, len(l2))
	ans += x - i - 1
print(ans)


n = int(input())
s = list(sorted([abs(i) for i in map(int, input().split())]))
l = 0
r = 1
ans = 0
while l < n - 1 or r < n:
	while r < n and s[l] * 2 >= s[r]:
		r += 1
	ans += r - l - 1
	l += 1
print(ans)


n = int(input())
lst = [int(i) for i in input().split()]
b = [abs(elem) for elem in lst]
b.sort()
(j, result) = (0, 0)
for i in range(n - 1):
	while j < n - 1 and b[j + 1] - b[i] <= b[i]:
		j += 1
	result += j - i
print(result)


n = int(input())
lis = sorted(map(abs, map(int, input().split())))
c = 0
i = j = 0
while i < n:
	while j < n and 2 * lis[i] >= lis[j]:
		j += 1
	i += 1
	c += j - i
print(c)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	l = [abs(x) for x in l]
	l.sort()
	i = 0
	j = 0
	ans = 0
	while i < n:
		while 2 * l[j] < l[i]:
			j += 1
		ans += i - j
		i += 1
	print(ans)
solution()


from sys import stdin, stdout
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import *
from random import *
from itertools import permutations
input = stdin.readline
prin = stdout.write
from random import sample
from collections import Counter, deque
from fractions import *
from math import sqrt, ceil, log2, gcd, cos, pi, floor
from copy import deepcopy
mod = 10 ** 9 + 7
mod2 = 998244353

def ps(n):
	cp = 0
	lk = 0
	arr = {}
	lk = 0
	ap = n
	cc = 0
	while n % 2 == 0:
		n = n // 2
		cc = 1
	if cc == 1:
		lk += 1
	for ps in range(3, ceil(sqrt(n)) + 1, 2):
		cc = 0
		while n % ps == 0:
			n = n // ps
			cc = 1
		lk += 1 if cc == 1 else 0
	if n != 1:
		lk += 1
	if lk == 1:
		return False
	return True

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def factorials(n, r):
	slr = n
	dpr = r
	qlr = 1
	qs = 1
	mod = 10 ** 9 + 7
	for ip in range(n - r + 1, n):
		qlr = qlr * ip % mod
	for ij in range(1, r):
		qs = qs * ij % mod
	ans = qlr * modInverse(qs) % mod
	return ans

def modInverse(b):
	qr = 10 ** 9 + 7
	return pow(b, qr - 2, qr)
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def power(arr):
	listrep = arr
	subsets = []
	for i in range(2 ** len(listrep)):
		subset = []
		for k in range(len(listrep)):
			if i & 1 << k:
				subset.append(listrep[k])
		subsets.append(subset)
	return subsets

def pda(n):
	list = []
	su = 0
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				list.append(i)
				su += i
			else:
				list.append(n // i)
				list.append(i)
				su += i
				su += n // i
	return su

def dis(xa, ya, xb, yb):
	return sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

def ii():
	return int(input())

def ilist():
	return [int(x) for x in input().strip().split()]

def islist():
	return list(map(str, input().split().rstrip()))

def inp():
	return input().strip()

def google(test):
	return 'Case #' + str(test) + ': '

def overlap(x1, y1, x2, y2):
	if x2 > y1:
		return y1 - x2
	if y1 > y2:
		return y2 - x2
	return y1 - x2

def dist(x1, y1, x2, y2):
	return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	ans = []
	for i in range(1, n + 1):
		if prime[i]:
			ans.append(i)
	return ans

def prod(arr):
	n = len(arr)
	k = 1
	for j in range(n):
		k *= arr[j]
	return k

def SumOfDigits(s):
	su = 0
	while s:
		su += s % 10
		s = s // 10
	return su

def std():
	return stdout.flush()

def finds(s):
	att = 0
	i = 1
	while i < len(s):
		att = int(s[:i])
		j = i
		cc = 0
		while j < len(s):
			att += 1
			sk = att
			news = str(sk)
			rr = len(news)
			if news == s[j:j + rr]:
				j += rr
			else:
				cc = 1
				break
		if cc == 0:
			return True
		i += 1
	return False
arr = []
for i in range(1, 10001):
	s = str(i)
	j = i
	while len(s) <= 7:
		j += 1
		s += str(j)
		arr.append(int(s))
arr.sort()

def subs(arr):
	res = set()
	pre = {0}
	for x in arr:
		pre = {x | y for y in pre} | {x}
		res |= pre
	return len(res)

def sl(n):
	return n * (n + 1) // 2
t = 1
for pl in range(t):
	n = ii()
	arr = ilist()
	pos = {}
	neg = {}
	for i in range(n):
		if arr[i] < 0:
			if -1 * arr[i] in neg:
				neg[-1 * arr[i]] += 1
			else:
				neg[-1 * arr[i]] = 1
		elif arr[i] in pos:
			pos[arr[i]] += 1
		else:
			pos[arr[i]] = 1
	for i in range(n):
		arr[i] = abs(arr[i])
	arr.sort()
	ans = 0
	checked = set()
	for i in range(n):
		if arr[i] not in checked:
			ant = br(arr, 2 * arr[i], 0, n)
			bnt = br(arr, arr[i], 0, n)
			co = 0
			if arr[i] in neg:
				co += neg[arr[i]]
			if arr[i] in pos:
				co += pos[arr[i]]
			ans += (ant - bnt) * co
			checked.add(arr[i])
	for tt in pos:
		if tt in neg:
			ans += pos[tt] * neg[tt]
	print(ans)


n = int(input())
a = list(map(lambda x: abs(int(x)), input().split()))
a.sort()
head = 0
tail = 1
result = 0
while tail <= n:
	while tail < n and a[head] * 2 >= a[tail]:
		tail += 1
	result += tail - 1 - head
	head += 1
	if tail == head:
		tail += 1
print(result)


import copy
n = int(input())
l = list(map(int, input().split()))
i = 0
while i < n:
	if l[i] == 0:
		l = l[:i] + l[i + 1:]
		n -= 1
	i += 1
p = n
l.sort()
for i in range(n):
	if l[i] > 0:
		p = i
		break
pos = copy.deepcopy(l[p:])
neg = copy.deepcopy(l[:p])
count = 0
i = 0
j = 0
while i < n - p:
	while j < n - p and pos[j] <= 2 * pos[i]:
		j += 1
	count += j - i - 1
	i += 1
i = p - 1
j = p - 1
while i > 0:
	while j >= 0 and neg[j] >= 2 * neg[i]:
		j -= 1
	count += i - j - 1
	i -= 1
i = 0
j = p - 1
k = p - 1
while i < n - p:
	while j >= 0 and abs(neg[j]) <= 2 * pos[i]:
		j -= 1
	while k >= 0 and abs(neg[k]) < pos[i] / 2:
		k -= 1
	count += k - j
	i += 1
print(count)


import bisect
n = int(input())
a = [abs(int(o)) for o in input().split()]
a = sorted(a)
ans = 0
for i in range(n):
	lol = 2 * a[i]
	ind = bisect.bisect(a, lol)
	ans += ind - i - 1
print(ans)


from bisect import bisect_right
a = int(input())
z = list(map(int, input().split()))
for i in range(len(z)):
	z[i] = abs(z[i])
z.sort()
x = 0
total = 0
for i in range(len(z)):
	x = bisect_right(z, 2 * z[i])
	x -= i + 1
	total += x
print(total)


from sys import *
from bisect import *
N = int(input())
pos = []
neg = []
A = list(map(int, stdin.readline().split()))
for a in A:
	if a > 0:
		pos += [a]
	else:
		neg += [-a]
pos.sort()
neg.sort()
ans = 0
for (i, x) in enumerate(pos):
	ans += max(0, bisect_right(pos, x * 2) - i - 1)
	l = bisect_left(neg, x)
	r = bisect_right(neg, x * 2)
	ans += max(0, r - l)
for (i, x) in enumerate(neg):
	ans += max(0, bisect_right(neg, x * 2) - i - 1)
	l = bisect_right(pos, x)
	r = bisect_right(pos, x * 2)
	ans += max(0, r - l)
print(ans)


from collections import deque
n = int(input().strip())
nums = list(map(int, input().strip().split()))
nums = sorted([abs(num) for num in nums], reverse=True)
res = 0
max_index = 0
curr_index = 1
for curr_index in range(1, n):
	while nums[curr_index] * 2 < nums[max_index]:
		max_index += 1
	res += curr_index - max_index
print(res)


num = int(input())
data = [abs(int(i)) for i in input().split()]
data.sort()

def bins(a, b, n):
	if a == b:
		if data[a] <= n:
			return a + 1
		else:
			return a
	else:
		m = (a + b) // 2
		if data[m] <= n:
			return bins(m + 1, b, n)
		else:
			return bins(a, m, n)
sum = 0
ind = 0
for i in range(num):
	while ind < num and data[ind] <= 2 * data[i]:
		ind += 1
	sum += ind - i - 1
print(sum)


def aTaleOfTwoLands(n, cor):
	z = 0
	sum = 0
	for i in range(n):
		max = 2 * cor[i]
		while z < n and cor[z] <= max:
			z = z + 1
		sum = sum + z - i - 1
	print(sum)

def main():
	n = int(input())
	cor = sorted([abs(int(i)) for i in input().split()])
	aTaleOfTwoLands(n, cor)
main()


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))
n = nn()
vals = lm()
avals = [abs(v) for v in vals]
avals.sort()
total = 0
start = 0
end = 1
while end < n:
	if 2 * avals[start] >= avals[end]:
		end += 1
	else:
		total = total + max(0, end - start - 1)
		start += 1
num = end - start
total += num * (num - 1) // 2
print(total)


n = int(input())
a = list(map(int, input().split()))
count = 0
(i, j) = (0, 0)
a = list(map(abs, a))
a.sort()
while i < n and j < n:
	y = a[i]
	x = a[j]
	if x <= 2 * y:
		if j < n - 1:
			j = j + 1
		else:
			count = count + (j - i)
			i = i + 1
	else:
		count = count + (j - 1 - i)
		i = i + 1
print(count)


n = int(input())
a = sorted(list(map(int, input().split())), key=lambda x: abs(x))
r = 0
ans = 0
for i in range(n):
	while r < n and abs(a[r]) <= abs(a[i] * 2):
		r += 1
	ans += r - i - 1
print(ans)


N = int(input())
List = list(map(int, input().split()))
for i in range(len(List)):
	List[i] = abs(List[i])
List.sort()
l = len(List) - 2
r = len(List) - 1
answer = 0
while l > -1:
	while 2 * List[l] >= List[r] and l > -1:
		l -= 1
	if l >= 0:
		answer += r - 1 - l
		r -= 1
	if l == -1:
		answer += r * (r + 1) / 2
		break
print(int(answer))


from sys import stdin, setrecursionlimit
from bisect import bisect_right
import math
setrecursionlimit(15000)
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
for i in range(n):
	arr[i] = abs(arr[i])
arr.sort()
count = 0
for i in range(n):
	index = bisect_right(arr, arr[i] * 2)
	count += index - i - 1
print(count)


from bisect import *
n = int(input())
l = [abs(int(i)) for i in input().split()]
l.sort()
ans = 0
for i in range(n):
	x = 0
	if l[i] % 2 == 0:
		x = l[i] // 2
	else:
		x = l[i] // 2 + 1
	ind = bisect_left(l, x)
	ans += i - ind
print(ans)


from bisect import bisect_right as br
seq = lambda : list(map(abs, map(int, input().strip().split())))
inp = lambda : int(input())
mul = lambda : map(int, input().strip().split())
n = inp()
t = seq()
t.sort()
ct = 0
for i in range(n):
	ind = br(t, 2 * t[i])
	ct += ind - i - 1
print(ct)


import sys
from bisect import *
rl = lambda : list(map(int, sys.stdin.readline().split()))
n = int(input())
A = rl()
A = sorted([abs(x) for x in A])
ans = 0
for i in range(n):
	idx = bisect_right(A, 2 * A[i])
	ans += abs(idx - i - 1)
print(ans)


import bisect
import sys
n = int(sys.stdin.readline())
a = [abs(int(x)) for x in sys.stdin.readline().split()]
a.sort()
ans = 0
for i in range(n):
	add = bisect.bisect(a, a[i] * 2) - i - 1
	ans += add
sys.stdout.write(str(ans))


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i - 1
	else:
		return len(a) - 1

def main():
	try:
		n = I()
		l = list(In())
		for i in range(n):
			l[i] = abs(l[i])
		l.sort()
		ans = 0
		for x in range(n):
			pos = find_gt(l, 2 * l[x])
			ans += pos - x
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


import math
n = int(input())
li = sorted([*map(lambda x: abs(int(x)), input().split())])
l = 0
r = 1
p = 0
total = 0
while r < n or l != r:
	if r == l:
		r += 1
		p = 0
	if r <= n - 1 and li[r] - li[l] <= li[l]:
		r += 1
		p += 1
	else:
		l += 1
		total += p if p >= 0 else 0
		p -= 1
print(total)


import bisect
N = int(input())
A = [abs(a) for a in map(int, input().split())]
A.sort()
ans = 0
for i in range(N):
	yi = bisect.bisect_right(A, A[i] * 2)
	if yi > i:
		ans += yi - i - 1
print(ans)


import bisect as bs
t = int(input())
it = list(map(int, input().split()))
tt = []
s = {}
for i in it:
	try:
		s[abs(i)] += 1
	except:
		s[abs(i)] = 1
		tt.append(abs(i))
tt.sort()
aa = [s[tt[0]]]
su = 0
for i in tt[1:]:
	aa.append(aa[-1] + s[i])
for i in range(len(tt)):
	k = tt[i]
	ind = bs.bisect_left(tt, 2 * k + 1)
	su += (aa[ind - 1] - aa[i]) * s[k] + (s[k] - 1)
print(su)


n = int(input())
a = list(map(int, input().split()))
import math
for i in range(n):
	a[i] = abs(a[i])
a.sort()
a.append(0)
j = 1
s = 0
for i in range(n):
	tem = a[i]
	while a[j] <= 2 * tem and j <= n - 1:
		j += 1
	s += j - i - 1
print(s)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = sorted([abs(a) for a in getInts()])
	i = 0
	j = 1
	ans = 0
	while i < N:
		while j < N and A[j] <= 2 * A[i]:
			j += 1
		ans += j - i - 1
		i += 1
	return ans
print(solve())


import sys
input = sys.stdin.readline
n = int(input())
l = [abs(int(i)) for i in input().split()]
l = sorted(l)
p = 0
q = 1
ans = 0
while q < n:
	while l[p] < l[q] / 2:
		p += 1
	ans += q - p
	q += 1
print(ans)


from bisect import bisect
N = int(input())
s = [int(x) for x in input().split()]
ans = 0
for i in range(0, len(s)):
	s[i] = abs(s[i])
L = sorted(s)
for i in range(0, len(L)):
	t = bisect(L, 2 * L[i])
	ans = ans + t - i - 1
print(ans)


import bisect
n = int(input())
L = list(map(abs, map(int, input().split())))
L.sort()
count = 0
flg = 0
for i in range(n):
	j = bisect.bisect_left(L, 2 * L[i] + 1)
	if j < n:
		count += j - 1 - i
	else:
		count += (n - i - 1 + 1) * (n - i - 1) / 2
		break
print(int(count))


n = int(input())
arr = list(map(lambda x: abs(int(x)), input().split()))
arr.sort()
ans = 0
i = 0
for j in range(n):
	while arr[i] * 2 < arr[j]:
		i += 1
	ans += j - i
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = list(map(abs, a))
a.sort()
a.append(10 ** 10)
low = 0
high = 0
tot = 0
while low < n:
	if a[high] <= 2 * a[low]:
		high += 1
	else:
		tot += high - low - 1
		low += 1
print(tot)


import bisect
n = int(input())
arr = [abs(int(x)) for x in input().split()]
arr.sort()
l = 0
for i in range(n - 1):
	var = bisect.bisect_right(arr, 2 * arr[i])
	l += var - i - 1
print(l)


n = int(input())
arr = [abs(int(i)) for i in input().split(' ')]
arr.sort()
ans = 0
j = 0
for i in range(n):
	x = arr[i]
	while j < n:
		y = arr[j]
		if abs(x - y) <= abs(x) <= x + y and abs(x - y) <= abs(y) <= x + y:
			j += 1
		else:
			break
	ans += j - i - 1
print(ans)


import sys
input = sys.stdin.readline
from math import *
n = int(input())

def can(a, b):
	m1 = max(abs(a), abs(b))
	m2 = min(abs(a), abs(b))
	p = abs(a - b)
	q = abs(a + b)
	if q > p:
		(p, q) = (q, p)
	if q <= m2 <= m1 <= p:
		return 1
	return 0
a = [int(x) for x in input().split()]
b = []
for i in a:
	b.append(abs(i))
a = b
a.sort()
n = len(a)
c = 0
for i in range(n):
	l = i + 1
	r = n - 1
	ans = i
	while l <= r:
		mid = l + (r - l) // 2
		if can(a[i], a[mid]):
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	c += ans - i
print(c)


n = int(input())
ls = list(map(int, input().split()))
ls = [abs(i) for i in ls]
ls.sort()
i = 0
j = 1
res = []
try:
	while True:
		while ls[j] <= 2 * ls[i]:
			j += 1
		res.append(j - i - 1)
		i += 1
except:
	while i != n:
		res.append(j - i - 1)
		i += 1
print(sum(res))


import sys, os
import bisect
f = lambda : list(map(int, input().split()))
if 'local' in os.environ:
	sys.stdin = open('./input.txt', 'r')

def solve():
	n = f()[0]
	a = f()
	a = [abs(i) for i in a]
	a = sorted(a)
	ans = 0
	for i in range(n):
		ans += bisect.bisect_right(a, a[i] * 2) - i - 1
	print(ans)
solve()


n = int(input())
arr = sorted(list(map(lambda x: abs(int(x)), input().split())), reverse=True)
count = 0
r = 1
for i in range(len(arr)):
	while r < n and arr[i] / 2 <= arr[r]:
		r += 1
	count += r - i - 1
print(count)


n = int(input())
a = list(map(abs, map(int, input().split())))
a.sort()
(ans, l) = (0, 0)
for i in range(1, n):
	while l < i and 2 * a[l] < a[i]:
		l += 1
	ans += i - l
print(ans)


from sys import stdin, stdout
import bisect as bs
for _ in range(1):
	n = int(stdin.readline())
	a = sorted(map(lambda x: abs(int(x)), stdin.readline().split()))
	ans = 0
	for i in range(n):
		pos = bs.bisect_left(a, 2 * a[i] + 1)
		pos -= 1
		ans += pos - i
	print(ans)


n = int(input())
A = sorted(map(abs, map(int, input().split())))
j = 0
count = 0
for i in range(n - 1):
	while j < n - 1 and A[j + 1] <= 2 * A[i]:
		j += 1
	count += j - i
print(count)


import math
import bisect as bs
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
n = len(a)
for i in range(n):
	a[i] = abs(a[i])
a.sort()
ans = 0
for i in range(n):
	k = bs.bisect_left(a, math.ceil(a[i] / 2))
	k = i - k
	ans += k
print(ans)


n = int(input())
a = [abs(int(i)) for i in input().split()]
a.sort()
y = 0
x = 0
ans = 0
while x < n:
	while y < n - 1 and a[x] * 2 >= a[y + 1]:
		y += 1
	ans += y - x
	x += 1
print(ans)


def main():
	n = int(input())
	arr = [int(i) for i in input().split()]
	new_arr = sorted([abs(i) for i in arr])
	count = 0
	j_ptr = 1
	i_ptr = 0
	while i_ptr < n:
		x = new_arr[i_ptr]
		while j_ptr < n:
			if new_arr[j_ptr] <= 2 * x:
				j_ptr += 1
			else:
				break
		count += j_ptr - i_ptr - 1
		i_ptr += 1
	print(count)
main()


n = int(input())
l = list(map(abs, list(map(int, input().split()))))
l.sort()
ans = 0
i = j = 0
while i < n:
	z = l[i] * 2
	while j < n and z >= l[j]:
		j += 1
	ans += j - i - 1
	i += 1
print(ans)


N = int(input())
A = sorted([abs(int(a)) for a in input().split()])
i = 0
j = 1
ans = 0
while j < N:
	while j < N - 1 and A[j + 1] <= A[i] * 2:
		j += 1
	if A[j] <= A[i] * 2:
		ans += j - i
	i += 1
	if j == i:
		j += 1
print(ans)


import bisect
n = int(input())
a = list(map(int, input().split()))
a = [abs(i) for i in a]
a.sort()
ans = 0
for i in range(len(a)):
	right = a[i] * 2
	ans += bisect.bisect_right(a, right) - (i + 1)
print(ans)


n = int(input())
a = [abs(int(i)) for i in input().split()]
a.sort()
ptr = 0
ans = 0
for x in range(1, len(a)):
	if a[x] - a[ptr] <= a[ptr]:
		ans += x - ptr
	else:
		while ptr != x:
			if a[x] - a[ptr] <= a[ptr]:
				ans += x - ptr
				break
			ptr += 1
print(ans)


from bisect import bisect_left

def solve():
	N = int(input())
	A = [abs(int(k)) for k in input().split()]
	A.sort()
	ans = 0
	for i in range(N - 1):
		pos = bisect_left(A, 2 * A[i])
		if pos == N or A[pos] > 2 * A[i]:
			pos -= 1
		if pos < N - 1 and A[pos] == A[pos + 1]:
			pos += 1
		if pos > i:
			ans += pos - i
	print(ans)
solve()


def he(i):
	return abs(int(i))
n = int(input())
arr = list(map(he, input().split(' ')))
arr.sort()
ans = 0
j = 1
i = 0
while i < n and j < n:
	if i < j:
		if 2 * arr[i] >= arr[j]:
			ans += j - i
			j += 1
		else:
			i += 1
	if i == j:
		j += 1
print(ans)


import bisect
n = int(input())
arr = [abs(int(x)) for x in input().split()]
arr.sort()
print(sum((bisect.bisect_right(arr, 2 * arr[x], 0, n) - x - 1 for x in range(0, n))))


from bisect import bisect_left
n = int(input())
a = [int(e) for e in input().split(' ')]
a.sort()
ans = 0
for (i, e) in enumerate(a):
	if e < 0:
		ind = bisect_left(a, e / 2)
		if ind >= n:
			ind = n - 1
		if a[ind] > e / 2:
			ind -= 1
		ans += ind - i
		ind1 = bisect_left(a, -e / 2)
		if ind1 < n:
			ind2 = bisect_left(a, -2 * e)
			if ind2 >= n:
				ind2 = n - 1
			if a[ind2] > -2 * e:
				ind2 -= 1
			ans += ind2 - ind1 + 1
	elif e > 0:
		ind = bisect_left(a, 2 * e)
		if ind >= n:
			ind = n - 1
		if a[ind] > 2 * e:
			ind -= 1
		ans += ind - i
print(ans)


from bisect import bisect_left

def f(n, arr):
	ans = 0
	for (i, val) in enumerate(arr):
		j = bisect_left(arr, val * 2 + 0.1)
		ans += j - 1 - i
	return ans

def main():
	n = int(input())
	arr = sorted(list(map(lambda x: abs(int(x)), input().split())))
	print(f(n, arr))
main()


import bisect
n = int(input(''))
a = list(map(int, input().split()))
for i in range(n):
	if a[i] < 0:
		a[i] = a[i] * -1
a.sort()
cnt = 0
for i in range(n):
	if a[i] == 0:
		cnt += 0
	else:
		t = bisect.bisect_left(a, 2 * a[i] + 1) - 1
		cnt += t - i
print(cnt)


from bisect import bisect_left
number_of_choices = 0
choices = []
result = 0

def Input(number_of_choices, choices):
	number_of_choices = int(input())
	choices = list(map(int, input().split()))
	return (number_of_choices, choices)

def Process(number_of_choices, choices, result):
	for index in range(number_of_choices):
		choices[index] = abs(choices[index])
	choices.sort()
	result = 0
	for index in range(number_of_choices):
		medium = choices[index] // 2
		if choices[index] % 2 == 1:
			medium += 1
		found_index = bisect_left(choices, medium)
		if choices[found_index] < medium:
			continue
		result += index - found_index
	return (number_of_choices, choices, result)

def Output(result):
	print(result)
(number_of_choices, choices) = Input(number_of_choices, choices)
(number_of_choices, choices, result) = Process(number_of_choices, choices, result)
Output(result)


n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
j = 1
j1 = 1
c = 0
x = 0
for i in range(0, n - 1):
	while j < n:
		if l[j] <= 2 * l[i]:
			c += 1
			j += 1
		else:
			break
	x = x + c + j1 - i - 1
	c = 0
	j1 = j
print(x)


import bisect

def solve(n, arr):
	arr = sorted([abs(a) for a in arr])
	res = 0
	(dposX, dpos2X) = ({}, {})
	for x in arr:
		if x in dposX:
			posX = dposX[x]
		i = dposX[x] = bisect.bisect_left(arr, x)
		if 2 * x in dpos2X:
			pos2X = dpos2X[x]
		j = dpos2X[x] = bisect.bisect(arr, 2 * x)
		res += j - i - 1
	res -= len(arr) - len(set(arr))
	return res

def test():
	from sys import stdin
	T = int(stdin.readline().strip())
	for _ in range(T):
		n = int(stdin.readline().strip())
		arr = list(map(int, stdin.readline().strip().split()))
		print(solve(n, arr))

def main():
	from sys import stdin
	n = int(stdin.readline().strip())
	arr = list(map(int, stdin.readline().strip().split()))
	print(solve(n, arr))
main()


n = int(input())
a = [abs(int(x)) for x in input().split()]
a.sort()
ct = 0
j = 0
sum = 0
for i in range(n):
	while j < n and a[j] <= 2 * a[i]:
		ct += 1
		j += 1
	sum += ct
sum -= (n * n + n) // 2
print(sum)


def bin(a, num, s, e, i):
	if s > e:
		if e <= i:
			return i
		else:
			return e
	mid = (s + e) // 2
	if a[mid] > num:
		return bin(a, num, s, mid - 1, i)
	elif a[mid] < num:
		return bin(a, num, mid + 1, e, i)
	else:
		return mid
n = int(input())
a = [abs(int(x)) for x in input().split()]
a.sort()
c = 0
temp = 1
for i in range(n):
	f = 1
	for j in range(temp, n):
		if a[j] > 2 * a[i]:
			temp = j - 1
			f = 0
			break
	if f:
		temp = n - 1
	c += temp - i
print(c)


import bisect, math
N = int(input())
a = sorted([abs(int(val)) for val in input().split()])
counts = [0 for _ in range(len(set(a)))]
index = {}
li = 0
for k in a:
	if k not in index:
		index[k] = li
		li += 1
	counts[index[k]] += 1
for i in range(1, len(counts)):
	counts[i] += counts[i - 1]
counts.insert(0, 0)
items = list(index.keys())

def get_index(x):
	i = bisect.bisect_left(items, x)
	if items[i] == x:
		i += 1
	return i
c = 0
for q in set(a):
	cc = counts[get_index(q)] - counts[get_index(q) - 1]
	sc = counts[get_index(q - 1)] - counts[get_index((q - 1) // 2)]
	c += cc * sc + cc * (cc - 1) // 2
print(c)


n = int(input(''))
su = 0
p = 1.2
l = 1
k = [abs(int(x)) for x in input('').split(' ')]
k1 = sorted(k)
km = k1[-1]
k1.append(2 * km + 1)
for j in range(n - 1):
	i = k1[j]
	if i == p:
		su += l - j - 1
		continue
	while k1[l] <= 2 * i and l < n:
		l += 1
	su += l - j - 1
	p = i
print(su)


n = int(input())
ar = list(map(int, input().split()))
for i in range(n):
	ar[i] = abs(ar[i])
ar.sort()
j = 1
ans = 0
for i in range(n):
	while j < n and ar[j] <= 2 * ar[i]:
		j += 1
	ans = ans + j - i - 1
print(ans)


from functools import lru_cache
import collections
import math
N = int(input())
arr = list(map(int, input('').split()))
arr = [abs(a) for a in arr if a != 0]
arr = sorted(arr)
N = len(arr)
ans = 0
idx = 1
i = 0
while i < N and idx < N:
	if arr[i] * 2 >= arr[idx]:
		ans += idx - i
		idx += 1
	else:
		i += 1
	if idx >= N:
		break
print(ans)


import math
n = int(input())
a = input().split()
for i in range(n):
	a[i] = abs(int(a[i]))
a = sorted(a)
s = 0
for i in range(1, n):
	if a[i - 1] * 2 < a[i]:
		continue
	l = 0
	r = i - 1
	while r != l:
		sr = (r + l) // 2
		if a[sr] * 2 >= a[i]:
			r = sr
		else:
			l = sr + 1
	s += i - l
print(s)


def main():
	from math import ceil
	from bisect import bisect_right, bisect_left
	n = int(input())
	a = sorted([abs(int(i)) for i in input().split()])
	ans = 0
	for i in range(n):
		l = bisect_left(a, ceil(a[i] / 2)) - 1
		r = bisect_right(a, a[i] * 2) - 1
		if l == -1 or a[l] * 2 < a[i]:
			l += 1
		if a[r] > a[i] * 2 or r == n:
			r -= 1
		if i > l and a[i] <= a[l] * 2:
			ans += i - l
		if i < r and a[i] * 2 >= a[r]:
			ans += r - i
	ans //= 2
	print(ans)
main()


n = int(input())
s = input()
ns = list(map(lambda x: abs(int(x)), s.split()))
ns.sort()
i = 0
j = 1
sum = 0
while True:
	t = 0
	while ns[j] <= ns[i] * 2:
		j += 1
		if j == n:
			t = n - 1
			break
	else:
		t = j - 1
	j = t
	sum += j - i
	if i < n - 2:
		i += 1
	else:
		break
	if j < n - 1:
		j += 1
print(sum)


n = int(input())
s = list(map(lambda x: abs(int(x)), input().split()))
s.sort()
r = 0
from bisect import bisect
for i in s:
	r += bisect(s, 2 * i) - bisect(s, i - 1) - 1
print(r + len(set(s)) - len(s))


import bisect
import math
n = int(input())
lg = [math.fabs(int(j)) for j in input().split()]
lg.sort()
s = 0
for i in range(n - 1, -1, -1):
	s += i - bisect.bisect_left(lg, math.ceil(lg[i] / 2))
print(s)


from bisect import bisect_right, bisect_left
n = int(input())
a = [abs(int(x)) for x in input().split(' ')]
a.sort()
r = 0
for i in range(1, n):
	e = a[i]
	x = e // 2
	if e % 2:
		x += 1
	j = bisect_left(a, x)
	r += i - j
print(r)


RI = lambda : [int(x) for x in input().split()]
from collections import defaultdict as df
import sys
n = int(input())
l = RI()
for i in range(len(l)):
	l[i] = abs(l[i])
l.sort()
ans = 0
for i in range(len(l)):
	start = i
	end = n - 1
	while start <= end:
		mid = (start + end) // 2
		if l[mid] - l[i] > l[i]:
			end = mid - 1
		else:
			start = mid + 1
	ans += end - i
print(ans)


n = int(input())
L = sorted([abs(int(x)) for x in input().split()])
T = 0
for i in range(n - 1):
	(l, h) = (i, n - 1)
	while h != l:
		if L[(l + h + 1) // 2] <= 2 * L[i]:
			l = (l + h + 1) // 2
		else:
			h = (l + h) // 2
	T += l - i
print(T)


n = int(input())
a = list(map(abs, map(int, input().split())))
a.sort()
from bisect import bisect_left
ans = 0
for (i, e) in enumerate(a):
	x = bisect_left(a, (e + 1) // 2)
	ans += i - x
print(ans)


def bin(x, st, en):
	if st <= en:
		mid = (st + en) // 2
		if l[mid] <= 2 * x:
			if mid + 1 < len(l):
				if l[mid + 1] > 2 * x:
					return mid
			else:
				return mid
			return bin(x, mid + 1, en)
		elif l[mid] > 2 * x:
			return bin(x, st, mid - 1)
	else:
		return -1
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
count = 0
for i in range(n):
	z = bin(l[i], i + 1, n - 1)
	if z != -1:
		count += z - i
print(count)


n = int(input())
s = input().split()
v = [abs(int(x)) for x in s]
ans = 0
v.sort()
for i in range(n):
	lo = i + 1
	hi = n - 1
	pos = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		if v[mid] <= 2 * v[i]:
			pos = mid
			lo = mid + 1
		else:
			hi = mid - 1
	if pos != -1:
		ans += pos - i
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n):
	a[i] = abs(a[i])
a.sort()
res = 0
r = 1
for i in range(n - 1):
	while r < n and a[r] <= 2 * a[i]:
		r += 1
	res += r - i - 1
print(res)


import sys
import math
from bisect import bisect_right as br

def int_arr():
	return list(map(int, sys.stdin.readline().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = int_arr()
for i in range(n):
	if arr[i] < 0:
		arr[i] = arr[i] * -1
arr.sort()
ans = 0
for i in range(n):
	x = arr[i] * 2
	ind = br(arr, x, i + 1)
	ans += ind - 1 - i
print(ans)


import bisect
n = int(input())
arr = sorted(list(map(lambda x: abs(int(x)), input().split())))
pairs = 0
for i in range(n):
	pairs += bisect.bisect_right(arr, 2 * arr[i]) - i - 1
print(pairs)


def main():
	n = int(input())
	arr = [abs(int(a)) for a in input().split()]
	arr.sort()
	from bisect import bisect
	ans = 0
	for i in range(n):
		j = bisect(arr, 2 * arr[i])
		ans += max(0, j - i - 1)
	print(ans)
main()


from bisect import bisect_left
n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = abs(arr[i])
arr.sort()
ans = 0
for i in range(n):
	elem = arr[i]
	next_elem = 2 * elem + 1
	ind = bisect_left(arr, next_elem, 0, n)
	ans += ind - i - 1
print(ans)


from sys import stdin, stdout
from bisect import bisect_left, bisect_right

def BinarySearch(a, x):
	i = bisect_right(a, x)
	if i:
		return i - 1
	else:
		return -1

def findlefftright(a, x):
	t1 = BinarySearch(a, x)
	ele_left = t1 + 1
	ele_right = len(a) - ele_left
	return (ele_left, ele_right)
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().strip().split(' ')))
arr.sort()
p1 = []
n1 = []
for i in range(len(arr)):
	if arr[i] >= 0:
		p1 = arr[i:]
		n1 = arr[:i]
		break
if len(n1) == 0 and len(p1) == 0:
	n1 = arr
n1 = list(map(abs, n1))
n1.sort()
ans = 0
for i in range(len(n1)):
	t1 = ans
	ans += findlefftright(n1, 2 * abs(n1[i]))[0] - findlefftright(n1, n1[i])[0]
if len(p1) > 1:
	for i in range(len(p1)):
		t1 = ans
		ans += findlefftright(p1, 2 * p1[i])[0] - findlefftright(p1, p1[i])[0]
for i in range(len(n1)):
	t1 = ans
	if n1[i] % 2 == 0:
		ans += findlefftright(p1, 2 * abs(n1[i]))[0] - findlefftright(p1, abs(n1[i]) // 2 - 1)[0]
	else:
		ans += findlefftright(p1, 2 * abs(n1[i]))[0] - findlefftright(p1, abs(n1[i]) // 2)[0]
stdout.write(str(ans))


N = int(input())
A = list(map(int, input().split()))

def count(X, Y):
	res = 0
	r = 0
	r2 = 0
	Y = [-10 ** 10] + Y + [10 ** 10]
	for l in range(len(X)):
		xl = X[l]
		for _ in range(len(Y)):
			if Y[r + 1] <= 2 * xl:
				r += 1
				continue
			break
		for _ in range(len(Y)):
			if Y[r2 + 1] < xl:
				r2 += 1
				continue
			break
		res += max(0, r - r2)
	return res
AP = [a for a in A if a > 0]
AP.sort()
AN = [-a for a in A if a < 0]
AN.sort()
print(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))


from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a = list(sorted([max(i, -i) for i in a]))
ans = 0
for i in range(len(a)):
	left = bisect_left(a, a[i] / 2)
	ans += i - left
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = sorted([abs(x) for x in a])
total = 0
i = 0
for (j, h) in enumerate(a[:-1]):
	h *= 2
	while i < n - 1 and a[i + 1] <= h:
		i += 1
	total += i - j
print(total)


from sys import stdin, stdout

def input():
	return stdin.readline()[:-1]
import math

def abs_int(a):
	return abs(int(a))
n = int(input())
a = list(map(abs_int, input().split()))
a.sort()
ptr = 0
half = -1
gt_than_half = [0] * n
for i in range(n):
	half = math.ceil(a[i] / 2)
	while a[ptr] < half:
		ptr += 1
	gt_than_half[i] = i - ptr
a.reverse()
ptr = 0
twice = -1
lt_than_twice = [0] * n
for i in range(n):
	twice = 2 * a[i]
	while a[ptr] > twice:
		ptr += 1
	lt_than_twice[i] = i - ptr
print((sum(gt_than_half) + sum(lt_than_twice)) // 2)


n = int(input())
a = [int(i) for i in input().split()]
rng = {}
i = 0
j = i + 1
a.sort(key=lambda x: abs(x))
ans = 0

def satisfy(x, y):
	old_x = abs(x)
	old_y = abs(y)
	mn = min(old_y, old_x)
	mx = max(old_x, old_x)
	new = [abs(y - x), abs(y + x)]
	if any((i <= mn for i in new)) and any((i >= mx for i in new)):
		return True
	return False
while j < len(a):
	while not satisfy(a[i], a[j]) and i < j:
		i += 1
	ans += j - i
	j += 1
print(ans)


n = int(input())
c = [abs(int(c)) for c in input().split()]
c = sorted(c)

def binsearch(nums, target, xy):
	left = xy
	right = len(nums) - 1
	while left <= right:
		mid = (left + right) // 2
		if nums[mid] == target:
			return mid
		elif nums[mid] > target:
			right = mid - 1
		elif nums[mid] < target:
			left = mid + 1
	return left - 1
res = 0
ans = 0
for x in range(n):
	res += binsearch(c, 2 * c[x], x) - x
pt1 = 0
if n == 2:
	if c[1] <= c[0] * 2:
		print(1)
	else:
		print(0)
	exit()
for i in range(n):
	while pt1 < n and c[pt1] <= 2 * c[i]:
		pt1 += 1
	if pt1 >= n or c[pt1] > 2 * c[i]:
		pt1 -= 1
	ans += pt1 - i
print(ans)


from bisect import bisect_right
n = int(input())
a = sorted([int(x) if int(x) >= 0 else -1 * int(x) for x in input().split()])
ans = 0
for i in range(n):
	p = bisect_right(a, 2 * a[i])
	ans += p - i - 1
print(ans)


from bisect import bisect_left as lb, bisect_right as ub

def legend(x, y):
	(a1, a2) = sorted([abs(x), abs(y)])
	(v1, v2) = sorted([abs(x - y), abs(x + y)])
	return True if v1 <= a1 and a2 <= v2 else False
input()
a = list(map(int, input().split()))
if 0 in a:
	a.remove(0)
a.sort()
t = 0
for x in a:
	t1 = 0
	if x < 0:
		b = ub(a, -x / 2)
		t += ub(a, x / 2) - ub(a, x)
		t += ub(a, -2 * x) - b
		if a[b - 1] == -x / 2:
			t += 1
	else:
		t += ub(a, 2 * x) - ub(a, x)
print(t)


class Tale:
	n = int(input())
	a = list(map(lambda x: abs(int(x)), input().split()))
	a.sort()
	counter = 0
	j = 0
	for i in range(n):
		while a[j] * 2 < a[i]:
			j += 1
		counter += i - j
	print(counter)


n = int(input())
a = list(map(int, input().split()))
a = [abs(x) for x in a]
a.sort()
count = 0
for i in range(n - 1):
	num = abs(a[i])
	l = +1
	r = n - 1
	while l < r:
		idex = (l + r + 1) // 2
		if abs(a[idex]) - abs(num) <= num:
			l = idex
		else:
			r = idex - 1
	if abs(num - abs(a[l])) <= num:
		count += l - i
print(count)


n = int(input())
a = sorted([abs(int(i)) for i in input().split()])
count = 0
j = 0
for i in range(n):
	lim = 2 * a[i]
	while j < n and a[j] <= lim:
		j += 1
	count += j - i - 1
print(count)


n = int(input())
a = [abs(int(i)) for i in input().split()]
a.sort()
count = 0
i = 0
j = 1
ans = 0
while i < n - 1:
	while j < n and a[j] <= 2 * a[i]:
		j = j + 1
	ans = ans + j - i - 1
	i = i + 1
print(ans)


from bisect import bisect_right
n = int(input())
a = list(map(int, input().split()))
a = [abs(a[i]) for i in range(n)]
a.sort()
ans = 0
for i in range(n):
	t = bisect_right(a, a[i] // 2)
	if a[t - 1] == a[i] // 2 and a[i] % 2 == 0:
		t -= 1
	while t > 0 and a[t] == a[t - 1]:
		t -= 1
	ans += i - t
print(ans)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	print('READ FROM FILE')
except:
	pass
n = int(input().rstrip())
a = sorted(map(abs, map(int, input().rstrip().split())))
ans = 0
l = 0
for r in range(1, n):
	while l < r and 2 * a[l] < a[r]:
		l += 1
	ans += r - l
print(ans)


import sys
DEBUG = False
if DEBUG:
	inf = open('input.txt')
else:
	inf = sys.stdin
N = int(inf.readline())
nums = sorted(map(abs, map(int, inf.readline().split())))

def finder(x, st):
	low = st
	high = N - 1
	sol = 0
	while low <= high:
		mid = (high + low) // 2
		if nums[mid] <= x:
			low = mid + 1
			sol = mid
		else:
			high = mid - 1
			sol = mid - 1
	return sol
tot = 0
ii = 1
for (i, num) in enumerate(nums):
	while ii < N and nums[ii] <= num * 2:
		ii += 1
	n = ii - i - 1
	tot += n
print(tot)


n = int(input())
l = list(map(int, input().split()))
a = [abs(l[i]) for i in range(n)]
a.sort()
wyn = 0
wsk1 = 0
wsk2 = 1
licz = 0
while True:
	if a[wsk1] * 2 < a[wsk2]:
		wyn += wsk2 - wsk1 - 1
		wsk1 += 1
	else:
		wsk2 += 1
	if wsk2 == n:
		break
wyn += (n - wsk1) * (n - wsk1 - 1) // 2
print(wyn)


n = int(input())
a = list(map(int, input().split()))
c = 0
a = [abs(i) for i in a]
a.sort()
j = 0
for i in range(n - 1):
	while j < n - 1 and a[j + 1] <= 2 * a[i]:
		j += 1
	c += j - i
print(c)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 998244353

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

def count(n):
	return n * (n + 1) // 2

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
A = [abs(int(x)) for x in input().split()]
A.sort()
ans = 0
j = 0
for i in range(n):
	x = A[i]
	while j < n:
		y = A[j]
		if abs(x - y) <= abs(x) <= abs(x + y) and abs(x - y) <= abs(y) <= abs(x + y):
			j += 1
		else:
			break
	ans += j - i - 1
print(ans)


import sys
read = sys.stdin.readline

def b_search(l, r, n):
	if l == r:
		if A[l] >= n:
			return l
		else:
			return l + 1
	mid = (l + r) // 2
	if A[mid] > n:
		return b_search(l, mid, n)
	elif A[mid] < n:
		return b_search(mid + 1, r, n)
	return mid
N = int(input())
A = list(map(int, read().split()))
for i in range(N):
	if A[i] < 0:
		A[i] = -A[i]
A.sort()
g_count = 0
for right in reversed(range(1, N)):
	half = A[right] // 2 if A[right] % 2 == 0 else (A[right] + 1) // 2
	idx = b_search(0, right - 1, half)
	if idx != right:
		while A[idx] < half:
			idx += 1
	if idx != 0:
		if A[idx] == A[idx - 1]:
			idx -= 1
	cnt = right - idx
	g_count += cnt
print(g_count)


from bisect import *
n = int(input())
a = sorted([abs(int(i)) for i in input().split()])
ans = 0
for (idx, ele) in enumerate(a):
	ans += max(bisect_right(a, ele * 2) - idx - 1, 0)
print(ans)


import sys
import bisect
import math

def input():
	return sys.stdin.readline().strip()
n = int(input())
q = list(map(int, input().split()))
for i in range(len(q)):
	q[i] = abs(q[i])
q.sort()
s = 0
for i in range(n):
	c1 = bisect.bisect_left(q, math.ceil(q[i] / 2)) - 1
	c2 = bisect.bisect_right(q, q[i] * 2) - 1
	if c1 == -1 or q[c1] * 2 < q[i]:
		c1 += 1
	if q[c2] > q[i] * 2 or c2 == n:
		c2 -= 1
	if i > c1 and q[i] <= q[c1] * 2:
		s += i - c1
	if i < c2 and q[i] * 2 >= q[c2]:
		s += c2 - i
print(s // 2)


import bisect

def main():
	n = int(input())
	a = [abs(int(x)) for x in input().split()]
	a.sort()
	ans = 0
	for i in range(n):
		ans += bisect.bisect_right(a, 2 * a[i]) - bisect.bisect_right(a, a[i])
		if a[i] == a[i - 1]:
			ans += 1
	print(ans)
main()


import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
for i in range(len(a)):
	if a[i] < 0:
		r = bisect.bisect_left(a, a[i] // 2 + 1)
		l = bisect.bisect_left(a, a[i] + 1)
		ans += r - l
		r = bisect.bisect_left(a, -a[i] * 2 + 1)
		l = bisect.bisect_left(a, -(a[i] // 2))
		ans += r - l
	elif a[i] > 0:
		r = bisect.bisect_left(a, 2 * a[i] + 1)
		l = bisect.bisect_left(a, a[i] + 1)
		ans += r - l
print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
a = sorted(list(map(abs, a)))
out = 0
i = 0
j = 1
while i < n:
	num = a[i]
	if j < n and a[j] <= 2 * num:
		j += 1
	else:
		out += max(0, j - 1 - i)
		i += 1
print(out)


def check_borders(n, borders):
	borders = sorted(borders, reverse=True, key=abs)
	num_of_pairs = 0
	current_x = 0
	current_y = 1
	while current_x != n - 1:
		diff = abs(borders[min(current_y, n - 1)]) >= abs(borders[current_x]) / 2
		if diff:
			while current_y < n and abs(borders[current_y]) >= abs(borders[current_x]) / 2:
				current_y += 1
			num_of_pairs += current_y - current_x - 1
		else:
			while not abs(borders[current_y]) >= abs(borders[current_x]) / 2:
				current_y -= 1
			num_of_pairs += current_y - current_x
		current_x += 1
	return num_of_pairs
n = int(input())
borders = list(map(int, input().split()))
print(check_borders(n, borders))


n = int(input())
a = map(int, input().split())
a = list((abs(i) for i in set(a)))
a.sort()
i = 0
j = 0
ans = 0
while i < len(a) - 1:
	while j < len(a) and a[j] <= 2 * a[i]:
		j += 1
	ans += j - i - 1
	i += 1
print(ans)


import sys, math, queue
MOD = 10 ** 9 + 7

def binleft(l, r, x):
	low = l
	high = r
	ans = None
	while low <= high:
		mid = (low + high) // 2
		if 2 * a[mid] < a[x]:
			ans = mid
			high = mid - 1
		else:
			low = mid + 1
	if 2 * a[0] >= a[x]:
		ans = -1
	if ans is None:
		return 0
	return r - ans

def binright(l, r, x):
	low = l
	high = r
	ans = None
	while low <= high:
		mid = (low + high) // 2
		if a[mid] <= 2 * a[x]:
			ans = mid
			low = mid + 1
		else:
			high = mid - 1
	if ans is None:
		return 0
	return ans - x
n = int(input())
a = sorted(map(lambda x: abs(int(x)), input().split()))
n = len(a)
lr = [0 for i in range(n)]
rr = [0 for i in range(n)]
ans = 0
for i in range(n):
	ans += binright(i + 1, n - 1, i)
print(ans)


import bisect
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
i = 0
ans = 0
while i < n:
	x = l[i]
	h = x / 2
	k = bisect.bisect_left(l, h) + 1
	ans += i - k + 1
	i += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = abs(a[i])
a.sort()
a.append(1000000000000000)
low = 0
high = 0
tot = 0
while low < n:
	if a[high] <= 2 * a[low]:
		high += 1
	else:
		tot += high - low - 1
		low += 1
print(tot)


from math import *
from collections import *
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	l[i] = abs(l[i])
l.sort()
j = n - 2
ans = [0 for i in range(n)]
for i in range(n - 1, -1, -1):
	while j > -1 and l[j] >= l[i] / 2:
		j -= 1
	ans[i] = i - j - 1
print(sum(ans))


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, a) = na()
for i in range(n):
	a[i] = abs(a[i])
a.sort()
j = 1
j1 = 1
dop = 0
ans = 0
for i in range(0, n - 1):
	while j < n:
		if a[j] <= 2 * a[i]:
			dop += 1
			j += 1
		else:
			break
	ans = ans + dop + j1 - i - 1
	dop = 0
	j1 = j
print(ans)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from bisect import *
n = ii()
l = sorted(list(map(lambda x: abs(int(x)), input().split())))
c = 0
for i in range(n):
	c += bisect_right(l, 2 * l[i]) - i - 1
print(c)


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def solve():
	n = int(input())
	arr = []
	for i in list_input():
		arr.append(abs(i))
	arr.sort()
	brr = []
	for i in arr:
		brr.append(math.ceil(i / 2))
	pairs = 0
	i = n - 1
	while i >= 0:
		arr.pop()
		indx = bisect.bisect_left(arr, brr[i])
		pairs += len(arr) - indx
		i -= 1
	print(pairs)
t = 1
for _ in range(t):
	solve()


from bisect import bisect, bisect_left
n = int(input())
ys = set(map(int, input().split())) - {0}
xs = sorted(ys)
ans = 0
for x in xs:
	if x > 0:
		break
	ans -= -x in ys
for x in xs:
	a = abs(x)
	aa = a * 2
	ans += bisect(xs, aa) - bisect_left(xs, a) + bisect(xs, -a) - bisect_left(xs, -aa) - 1
print(ans)


n = int(input())
a = []
d = list(map(int, input().split()))
for i in range(len(d)):
	a.append(abs(d[i]))
a.sort()
j = 0
c = 0
for i in range(n - 1):
	while j + 1 < n and a[j + 1] - a[i] <= a[i]:
		j = j + 1
	c = c + j - i
print(c)


import bisect
n = int(input())
x = [abs(int(g)) for g in input().split()]
count = 0
x.sort()
for i in range(n):
	double = 2 * x[i]
	l = bisect.bisect(x, double)
	index = l - i - 1
	count += index
print(count)


from sys import stdin, stdout
import bisect
from itertools import combinations
from collections import defaultdict, OrderedDict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
a = listIn()
a = [abs(x) for x in a]
a.sort()
count = Counter(a)
b = sorted(set(a))
l = len(b)
arr = [0] * n
for i in range(n):
	idx = bisect.bisect_right(a, 2 * a[i]) - 1
	arr[i] = idx - i
print(sum(arr))


import math
n = int(input())
lis = list(map(int, input().split()))
for i in range(len(lis)):
	lis[i] = abs(lis[i])
lis.sort()
ans = 0
i = 0
j = 1
while j < n:
	if i < j:
		if lis[j] - lis[i] <= lis[i]:
			ans += 1
			if j < n - 1:
				j += 1
			else:
				i += 1
				if i != j:
					ans += j - i - 1
		else:
			i += 1
			if i != j:
				ans += j - i - 1
	elif j == i and j < n - 1:
		j += 1
	else:
		break
print(ans)


import itertools
import collections
import heapq
import bisect
import math
import sys
import operator
import string
nc = int(input())
options = map(int, input().split())
absopts = list(map(abs, options))
absopts.sort()
tpos = 0
res = 0
for i in range(nc):
	while tpos < nc and absopts[tpos] <= absopts[i] * 2:
		tpos += 1
	res += max(0, tpos - i - 1)
print(res)


def calcindex(start, end, arr, num):
	if start == end:
		if arr[start] <= num:
			return end
		else:
			return end - 1
	else:
		mid = (start + end) // 2
		if arr[mid] > num and arr[mid - 1] <= num:
			return mid - 1
		elif arr[mid] > num:
			end = mid - 1
			return calcindex(start, end, arr, num)
		else:
			start = mid + 1
			return calcindex(start, end, arr, num)
n = int(input())
l = list(map(int, input().split()))
new = []
for i in l:
	if i > 0:
		new.append(i)
	else:
		new.append(i * -1)
new.sort()
count = 0
for i in range(n - 1):
	temp = calcindex(i + 1, n - 1, new, 2 * new[i])
	count += temp - i
print(count)