C. A Tale of Two Lands

problem_index: C

time_limit: 1 second

memory_limit: 256 megabytes

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](images/cf_1166_C/1.png)
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](images/cf_1166_C/2.png)
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](images/cf_1166_C/3.png)
Note that even though Arrayland and Vectorland share $$$3$$$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.

solutions: ["from sys import stdin\nfrom bisect import bisect\nn = int(input())\nl = list(map(int, stdin.readline().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\nans = 0\nfor i in range(n):\n\ta = bisect(l, 2 * l[i])\n\tans += a - i - 1\nprint(ans)\n", "import sys\ninput = sys.stdin.readline\nfrom bisect import bisect_right, bisect_left\nfrom collections import defaultdict\neps = 0.01\n\ndef get_count(a, l, r):\n\treturn bisect_right(a, r) - bisect_left(a, l)\n\nclass Problem:\n\n\tdef __init__(self):\n\t\tpass\n\n\tdef solve(self):\n\t\tprint(self._solve())\n\n\tdef _solve(self):\n\t\tn = int(input())\n\t\ta = [int(item) for item in input().split()]\n\t\tans = 0\n\t\td = defaultdict(int)\n\t\tfor x in a:\n\t\t\td[x] += 1\n\t\ta = sorted(set(list(a)))\n\t\tn = len(a)\n\t\tfor i in range(n):\n\t\t\tx = a[i]\n\t\t\tif x < 0:\n\t\t\t\tans += get_count(a, -x / 2, -2 * x) + get_count(a, x, x / 2) - 1\n\t\t\telse:\n\t\t\t\tans += get_count(a, x, 2 * x) - 1\n\t\tfor x in d:\n\t\t\tans += d[x] * (d[x] - 1) // 2\n\t\treturn ans\n\ndef main():\n\tproblem = Problem()\n\tproblem.solve()\nmain()\n", "import bisect\nn = int(input())\nz = sorted([abs(int(i)) for i in input().split()])\nsum = 0\nfor i in range(n):\n\ttmp = bisect.bisect(z, z[i] * 2)\n\tif tmp > i:\n\t\tsum = sum + (tmp - i - 1)\nprint(sum)\n", "import math\n\ndef read_task():\n\tn = int(input())\n\ttask = [abs(int(x)) for x in input().split()]\n\treturn task\n\ndef resolve(task):\n\ta = sorted(task)\n\ta.append(float('+inf'))\n\tcount = 0\n\tj = 0\n\tfor i in range(len(a) - 2):\n\t\twhile a[j + 1] <= 2 * a[i]:\n\t\t\tj += 1\n\t\tif j > i:\n\t\t\tcount += j - i\n\treturn count\n\ndef print_solution(solution):\n\tprint(solution)\n\ndef main():\n\ttask = read_task()\n\tsolution = resolve(task)\n\tprint_solution(solution)\nmain()\n", "n = int(input())\na = list(map(int, input().split()))\nfrom bisect import bisect_right as br\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\nans = 0\nfor i in range(n):\n\tj = br(a, 2 * a[i]) - 1\n\tans += j - i\nprint(ans)\n", "import sys\ntry:\n\tsys.stdin = open('in.in', 'r')\nexcept:\n\tpass\nn = int(input())\na = list(map(lambda x: abs(int(x)), input().split()))\na.sort()\nl = 0\nans = 0\nfor r in range(n):\n\twhile l < r and a[l] * 2 < a[r]:\n\t\tl += 1\n\tans += r - l\nprint(ans)\n", "n = int(input())\na = sorted(map(abs, map(int, input().split())))\nj = ans = 0\nfor i in range(n):\n\twhile 2 * a[j] < a[i]:\n\t\tj += 1\n\tans += i - j\nprint(ans)\n", "n = int(input())\nnums = (abs(int(x)) for x in input().split())\nnums = list(sorted(nums))\nleft = 0\nright = 0\nans = 0\nwhile left < n:\n\twhile right < n and nums[right] <= 2 * nums[left]:\n\t\tright += 1\n\tans += right - left - 1\n\tleft += 1\nprint(ans)\n", "n = int(input())\na = sorted([int(q) for q in input().split()], key=lambda x: (abs(x), x))\nans = q1 = q2 = 0\nfor q in range(len(a)):\n\twhile len(a) > q2 and a[q2] == a[q]:\n\t\tq2 += 1\n\twhile len(a) > q1 and abs(a[q1]) <= 2 * abs(a[q]):\n\t\tq1 += 1\n\tans += q1 - q2\nprint(ans)\n", "n = int(input())\nA = list(map(int, input().split()))\nfor i in range(n):\n\tif A[i] < 0:\n\t\tA[i] = abs(A[i])\nans = 0\ni = 0\nj = 1\nA.sort()\nwhile i < n and j < n:\n\tif A[j] <= 2 * A[i]:\n\t\tj += 1\n\telse:\n\t\tans += j - i - 1\n\t\ti += 1\n\t\tif i == j:\n\t\t\tj += 1\nans += (j - i - 1) * (j - i) // 2\nprint(ans)\n", "n = int(input())\na = sorted(map(abs, map(int, input().split())))\nr = i = j = 0\nwhile i < n:\n\twhile 2 * a[j] < a[i]:\n\t\tj += 1\n\tr += i - j\n\ti += 1\nprint(r)\n", "from sys import *\nfrom math import *\nfrom bisect import *\nn = int(stdin.readline())\na = list(map(int, stdin.readline().split()))\nfor i in range(n):\n\tif a[i] < 0:\n\t\ta[i] = -a[i]\na.sort()\nans = 0\nfor i in range(n):\n\tx = bisect_right(a, 2 * a[i])\n\tans += x - i - 1\nprint(ans)\n", "import math\nimport re\nimport sys\nfrom collections import defaultdict\nfrom heapq import heappush, heappop\nfrom fractions import gcd\n\ndef read(type=int):\n\treturn type(input())\n\ndef read_list(type=int, split=' ', F=None):\n\tif F:\n\t\treturn map(lambda x: F(type(x)), raw_input().split(split))\n\treturn map(type, input().split(split))\n\ndef read_list_of_list(N, type=int, split=' ', F=None):\n\treturn [read_list(type, F=F) for _ in range(N)]\nn = read()\nA = read_list()\nA = list(sorted(map(abs, A)))\ni = j = R = 0\nwhile i < n:\n\twhile j < n and A[j] - A[i] <= A[i]:\n\t\tj += 1\n\tR += j - 1 - i\n\ti += 1\nprint(R)\n", "import bisect\n\ndef main():\n\tn = int(input())\n\tpts = list(map(int, input().split()))\n\tpoints = []\n\tfor i in range(n):\n\t\tpoints.append(abs(pts[i]))\n\tpoints.sort()\n\tpairs = 0\n\tfor i in range(n):\n\t\tx = points[i]\n\t\tindex = bisect.bisect(points, 2 * x) - 1\n\t\tif points[index] <= 2 * x:\n\t\t\tif index >= i:\n\t\t\t\tpairs += index - i\n\tprint(pairs)\nmain()\n", "n = int(input())\nl = [abs(int(x)) for x in input().split()]\nl = sorted(l)\nans = 0\nleft = 0\nfor right in range(n):\n\twhile left < right and l[right] > 2 * l[left]:\n\t\tleft += 1\n\tans += right - left\nprint(ans)\n", "import bisect\nn = int(input())\nl = [abs(int(x)) for x in input().split()]\nl.sort()\nres = 0\nfor i in range(n - 1):\n\tb = bisect.bisect_right(l, 2 * l[i], i + 1)\n\tres += b - i - 1\nprint(res)\n", "import bisect\nn = int(input())\narr = list(map(int, input().split()))\narr.sort()\nfor i in range(n):\n\tarr[i] = abs(arr[i])\narr.sort()\nans = 0\nfor i in range(n):\n\ttemp = bisect.bisect_right(arr, 2 * arr[i], i)\n\tans += max(0, temp - i - 1)\nprint(ans)\n", "def getN():\n\treturn int(input())\n\ndef getList():\n\treturn list(map(int, input().split()))\nfrom bisect import bisect_right\nn = getN()\nnums = [abs(i) for i in getList()]\nnums.sort(reverse=False)\nans = 0\nfor (i, num) in enumerate(nums):\n\tans += bisect_right(nums, num * 2) - i - 1\nprint(ans)\n", "import sys\nn = int(input())\na = [abs(int(x)) for x in input().split()]\na.sort()\n(rt, rez) = (n - 1, 0)\nfor i in range(n - 1, -1, -1):\n\tlim = (a[i] + 1) // 2\n\twhile rt >= 0 and a[rt] >= lim:\n\t\trt -= 1\n\trez += i - rt - 1\nprint(rez)\n", "def lower(a, t):\n\tl = 0\n\tr = len(a) - 1\n\tans = 0\n\twhile r - l >= 0:\n\t\tmid = (l + r) // 2\n\t\tif abs(a[mid]) < t:\n\t\t\tl = mid + 1\n\t\tif abs(a[mid]) >= t:\n\t\t\tr = mid - 1\n\t\t\tans = mid\n\treturn ans\n\ndef upper(a, t):\n\tl = 0\n\tr = len(a) - 1\n\tans = 0\n\twhile r - l >= 0:\n\t\tmid = (l + r) // 2\n\t\tif abs(a[mid]) <= t:\n\t\t\tl = mid + 1\n\t\t\tans = mid\n\t\tif abs(a[mid]) > t:\n\t\t\tr = mid - 1\n\treturn ans\nn = int(input())\na = list(map(int, input().split()))\na.sort(key=abs)\nct = 0\nfor i in a:\n\tct += upper(a, abs(i) * 2) - lower(a, abs(i) / 2)\nprint(ct // 2)\n", "n = int(input())\nA = [abs(int(i)) for i in input().split()]\nA.sort()\nans = 0\n\ndef b_search(ok, ng, comp):\n\twhile abs(ok - ng) > 1:\n\t\tmid = (ok + ng) // 2\n\t\tif comp(mid):\n\t\t\tok = mid\n\t\telse:\n\t\t\tng = mid\n\treturn ok\nprev = -1\nfor a in A:\n\tif prev == a:\n\t\tans -= 1\n\tprev = a\n\tleft = b_search(n, -1, lambda x: A[x] >= a)\n\tright = b_search(-1, n, lambda x: A[x] <= 2 * a)\n\tans += max(0, right - left)\nprint(ans)\n", "from bisect import bisect_right\nimport sys\ninput = sys.stdin.readline\nN = int(input())\nA = list(map(lambda x: abs(int(x)), input().split()))\nA.sort()\nans = 0\nfor i in range(N):\n\tib = bisect_right(A, A[i] * 2)\n\tans += ib - i - 1\nprint(ans)\n", "n = int(input())\na = [abs(int(x)) for x in input().split()]\na.sort()\ncount = 0\nl = 0\nr = 0\nwhile l < n:\n\twhile r < n and 2 * a[l] >= a[r]:\n\t\tr += 1\n\tcount += r - l - 1\n\tl += 1\nprint(count)\n", "def main():\n\tn = int(input())\n\ta = sorted(map(abs, list(map(int, input().split()))))\n\ti = 0\n\tres = 0\n\tfor j in range(n):\n\t\twhile a[i] * 2 < a[j]:\n\t\t\ti += 1\n\t\tres += j - i\n\tprint(res)\nmain()\n", "n = int(input())\nl = sorted([abs(int(i)) for i in input().split()])\nans = 0\n(i, j) = (0, 0)\nwhile i < n:\n\twhile j < n and l[i] + l[i] >= l[j]:\n\t\tj += 1\n\tans += j - i - 1\n\ti += 1\nprint(ans)\n", "n = int(input())\na = sorted([int(x) for x in input().split()])\ncounter = 0\nanswer = 0\nend = 1\nfor i in range(n):\n\tif a[i] < 0:\n\t\ta[i] = a[i] * -1\na.sort()\nfor i in range(n):\n\tend = max(end, i + 1)\n\tfor j in range(end, n):\n\t\tif a[i] * 2 < a[j]:\n\t\t\tend = j\n\t\t\tbreak\n\t\telse:\n\t\t\tcounter += 1\n\telse:\n\t\tend = j + 1\n\tanswer += counter\n\tcounter = max(counter - 1, 0)\nprint(answer)\n", "import sys\ninput = sys.stdin.readline\nn = int(input())\narr = list(map(int, input().split()))\narr.sort()\n\ndef binarySearch(l, r, x):\n\tif r >= l:\n\t\tmid = l + (r - l) // 2\n\t\tif arr[mid] > x and arr[mid - 1] <= x:\n\t\t\treturn mid\n\t\telif arr[mid] > x:\n\t\t\treturn binarySearch(l, mid - 1, x)\n\t\telse:\n\t\t\treturn binarySearch(mid + 1, r, x)\n\telse:\n\t\treturn -1\n\ndef mod(l, r, x):\n\tif r >= l:\n\t\tmid = l + (r - l) // 2\n\t\tif arr[mid] >= x and arr[mid - 1] < x:\n\t\t\treturn mid\n\t\telif arr[mid] > x:\n\t\t\treturn mod(l, mid - 1, x)\n\t\telse:\n\t\t\treturn mod(mid + 1, r, x)\n\telse:\n\t\treturn -1\ncount = 0\nfor i in range(n):\n\tcount += n\n\tcount -= i + 1\n\tif arr[i] < 0:\n\t\tbs1 = binarySearch(0, n - 1, 2 * abs(arr[i]))\n\t\tif bs1 >= 0:\n\t\t\tcount -= n - bs1\n\t\tbs2 = binarySearch(0, n - 1, -abs(arr[i] / 2))\n\t\tif bs2 >= 0:\n\t\t\tcount -= n - bs2\n\t\tbs3 = mod(0, n - 1, abs(arr[i] / 2))\n\t\tif bs3 >= 0:\n\t\t\tcount += n - bs3\n\telse:\n\t\tbs = binarySearch(0, n - 1, 2 * arr[i])\n\t\tif bs >= 0:\n\t\t\tcount -= n - bs\nprint(count)\n", "n = int(input())\nl = sorted((abs(int(a)) for a in input().split()))\nj = 0\nanswer = 0\nfor (i, a) in enumerate(l):\n\twhile j < n - 1 and l[j + 1] <= a << 1:\n\t\tj += 1\n\tanswer += j - i\nprint(answer)\n", "def fun(n):\n\treturn abs(int(n))\nn = int(input())\nseq = sorted(map(fun, input().split()))\nans = 0\ntmp = 0\nle = 0\nri = le + 1\nwhile le < n:\n\twhile ri < n and seq[ri] <= seq[le] * 2:\n\t\tri += 1\n\t\ttmp += 1\n\tans += tmp\n\tif tmp > 0:\n\t\ttmp -= 1\n\tle += 1\n\tif le == ri:\n\t\tri += 1\nprint(ans)\n", "import sys\nfrom collections import defaultdict as dd\nfrom collections import deque\nfrom functools import *\nfrom fractions import Fraction as f\nfrom copy import *\nfrom bisect import *\nfrom heapq import *\nfrom itertools import permutations, product\n\ndef eprint(*args):\n\tprint(*args, file=sys.stderr)\nzz = 1\nif zz:\n\tinput = sys.stdin.readline\nelse:\n\tsys.stdin = open('input.txt', 'r')\n\tsys.stdout = open('all.txt', 'w')\n\ndef inc(d, c, x=1):\n\td[c] = d[c] + x if c in d else x\n\ndef bo(i):\n\treturn ord(i) - ord('A')\n\ndef li():\n\treturn [int(xx) for xx in input().split()]\n\ndef fli():\n\treturn [float(x) for x in input().split()]\n\ndef comp(a, b):\n\tif a > b:\n\t\treturn 2\n\treturn 2 if a == b else 0\n\ndef gi():\n\treturn [xx for xx in input().split()]\n\ndef fi():\n\treturn int(input())\n\ndef pro(a):\n\treturn reduce(lambda a, b: a * b, a)\n\ndef swap(a, i, j):\n\t(a[i], a[j]) = (a[j], a[i])\n\ndef si():\n\treturn list(input().rstrip())\n\ndef mi():\n\treturn map(int, input().split())\n\ndef gh():\n\tsys.stdout.flush()\n\ndef isvalid(i, j):\n\treturn 0 <= i < n and 0 <= j < n\n\ndef bo(i):\n\treturn ord(i) - ord('a')\n\ndef graph(n, m):\n\tfor i in range(m):\n\t\t(x, y) = mi()\n\t\ta[x].append(y)\n\t\ta[y].append(x)\nt = 1\nwhile t > 0:\n\tt -= 1\n\tn = fi()\n\ta = li()\n\tfor i in range(n):\n\t\ta[i] = abs(a[i])\n\ta.sort()\n\tc = 0\n\tfor i in range(n):\n\t\tc += i - bisect_left(a, a[i] / 2)\n\tprint(c)\n", "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nn = int(input())\narr = list(map(lambda x: abs(int(x)), input().split()))\narr.sort()\ntotal = 0\nfor (i, e) in enumerate(arr):\n\ttotal += max(br(arr, e * 2) - i - 1, 0)\nprint(total)\n", "import bisect\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\nres = 0\nae = enumerate(a, start=0)\nfor (i, j) in ae:\n\tr = bisect.bisect(a, 2 * j)\n\tres += r - i - 1\nprint(res)\n", "from bisect import bisect_right\nn = int(input())\nA = list(map(int, input().split()))\nfor i in range(len(A)):\n\tA[i] = abs(A[i])\nA.sort()\ncnt = 0\nfor i in range(len(A)):\n\tq = 2 * A[i]\n\tj = bisect_right(A, q)\n\tcnt += max(0, j - i - 1)\nprint(cnt)\n", "n = int(input())\na = list(map(lambda x: abs(int(x)), input().split()))\na.sort()\nl = 0\nans = 0\nfor r in range(n):\n\twhile l < r and a[l] * 2 < a[r]:\n\t\tl += 1\n\tans += r - l\nprint(ans)\n", "N = int(input())\nList = sorted([abs(int(i)) for i in input().split()])\nl = len(List) - 2\nr = len(List) - 1\nanswer = 0\nwhile l > -1:\n\twhile 2 * List[l] >= List[r] and l > -1:\n\t\tl -= 1\n\tif l >= 0:\n\t\tanswer += r - 1 - l\n\t\tr -= 1\n\tif l == -1:\n\t\tanswer += r * (r + 1) / 2\n\t\tbreak\nprint(int(answer))\n", "import math\n\ndef solve(n):\n\tL = list(map(int, input().split()))\n\tres = 0\n\tfor i in range(n):\n\t\tL[i] = abs(L[i])\n\tL.sort()\n\tr = 1\n\tfor i in range(n - 1):\n\t\twhile r < n and L[r] <= L[i] * 2:\n\t\t\tr += 1\n\t\tres += r - i - 1\n\treturn res\n\tprint(L)\n\treturn L\nk = int(input())\nprint(solve(k))\n", "n = int(input())\na = sorted(list(map(lambda x: abs(int(x)), input().split())))\nret = 0\nfor i in range(n - 1):\n\tleft = i\n\tright = n\n\twhile right > left + 1:\n\t\tmid = (left + right) // 2\n\t\tif a[mid] - a[i] <= a[i]:\n\t\t\tleft = mid\n\t\telse:\n\t\t\tright = mid\n\tret += left - i\nprint(ret)\n", "from os import path\nimport sys\nfrom heapq import heappush, heappop\nfrom functools import cmp_to_key as ctk\nfrom collections import deque, defaultdict as dd\nfrom bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil, sqrt, log, gcd\n\ndef ii():\n\treturn int(input())\n\ndef si():\n\treturn input().rstrip()\n\ndef mi():\n\treturn map(int, input().split())\n\ndef li():\n\treturn list(mi())\nabc = 'abcdefghijklmnopqrstuvwxyz'\nmod = 1000000007\ninf = float('inf')\nvow = ['a', 'e', 'i', 'o', 'u']\n(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])\n\ndef bo(i):\n\treturn ord(i) - ord('a')\nfile = 1\n\ndef solve():\n\tn = ii()\n\ta = li()\n\t(pos, neg) = ([], [])\n\tfor i in range(n):\n\t\tif a[i] < 0:\n\t\t\ta[i] = abs(a[i])\n\tans = 0\n\ta.sort()\n\tfor i in range(n):\n\t\tx = 2 * a[i]\n\t\tl = i + 1\n\t\tr = n - 1\n\t\tp = -1\n\t\twhile l <= r:\n\t\t\tm = l + (r - l) // 2\n\t\t\tif a[m] <= x:\n\t\t\t\tl = m + 1\n\t\t\t\tp = m\n\t\t\telse:\n\t\t\t\tr = m - 1\n\t\tif p == -1:\n\t\t\tcontinue\n\t\tans += p - i\n\tprint(ans)\nif file:\n\tif path.exists('input.txt'):\n\t\tsys.stdin = open('input.txt', 'r')\n\t\tsys.stdout = open('output.txt', 'w')\n\telse:\n\t\tinput = sys.stdin.readline\nsolve()\n", "import sys\n\nclass Main:\n\n\tdef __init__(self):\n\t\tself.buff = None\n\t\tself.index = 0\n\n\tdef next(self):\n\t\tif self.buff is None or self.index == len(self.buff):\n\t\t\tself.buff = self.next_line()\n\t\t\tself.index = 0\n\t\tval = self.buff[self.index]\n\t\tself.index += 1\n\t\treturn val\n\n\tdef next_line(self):\n\t\treturn sys.stdin.readline().split()\n\n\tdef next_ints(self):\n\t\treturn [int(x) for x in sys.stdin.readline().split()]\n\n\tdef next_int(self):\n\t\treturn int(self.next())\n\n\tdef solve(self):\n\t\tk = self.next_int()\n\t\tx = sorted((abs(x) for x in self.next_ints()))\n\t\ti = 0\n\t\tr = 0\n\t\tfor j in range(k):\n\t\t\twhile x[j] - x[i] > x[i]:\n\t\t\t\ti += 1\n\t\t\tr += j - i\n\t\tprint(r)\nMain().solve()\n", "import sys\nfrom collections import Counter\nfrom bisect import bisect_right as br\n\ndef numofpairs(n):\n\treturn n * (n - 1) // 2\nn = int(sys.stdin.readline().strip())\nints = list(map(lambda x: abs(int(x)), sys.stdin.readline().split()))\nints.sort()\ncounter = 0\nfor (index, val) in enumerate(ints[:-1]):\n\tupperindex = br(ints, 2 * val) - 1\n\tindexspan = upperindex - index\n\tcounter += indexspan\nprint(counter)\n", "from sys import stdin, stdout\nfor _ in range(1):\n\tn = int(stdin.readline())\n\ta = sorted(map(lambda x: abs(int(x)), stdin.readline().split()))\n\tans = 0\n\tfor i in range(n):\n\t\tl = i\n\t\tr = n - 1\n\t\twhile l <= r:\n\t\t\tmid = l + r >> 1\n\t\t\tif a[mid] > 2 * a[i]:\n\t\t\t\tr = mid - 1\n\t\t\telse:\n\t\t\t\tl = mid + 1\n\t\tans += r - i\n\tprint(ans)\n", "from bisect import bisect\n(n, a) = (int(input()), [*map(int, input().split())])\nb = sorted((abs(x) for x in a))\nprint(sum((bisect(b, 2 * x, i) - i - 1 for (i, x) in enumerate(b))))\n", "N = int(input())\narr = input()\narr = [int(x) for x in arr.split(' ')]\narr = sorted(arr, key=abs)\nidx1 = 0\nidx2 = 1\nans = 0\nwhile idx1 < N or idx2 < N:\n\tif idx2 == N:\n\t\tans += idx2 - 1 - idx1\n\t\tidx1 += 1\n\telif abs(arr[idx1]) * 2 < abs(arr[idx2]):\n\t\tans += idx2 - 1 - idx1\n\t\tidx1 += 1\n\telif abs(arr[idx1]) * 2 >= abs(arr[idx2]):\n\t\tidx2 += 1\nprint(ans)\n", "import bisect\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(len(a)):\n\tif a[i] < 0:\n\t\ta[i] = -a[i]\na.sort()\ncount = 0\nfor i in range(1, len(a)):\n\tind = bisect.bisect_left(a, a[i] / 2, 0, i)\n\tif ind < i:\n\t\tcount += i - ind\nprint(count)\n", "n = int(input())\nx = [abs(int(w)) for w in input().split()]\nx = sorted(x)\nans = 0\nj = 0\nfor i in range(n):\n\twhile 2 * x[j] < x[i]:\n\t\tj += 1\n\tans += i - j\nprint(ans)\n", "import os\nimport sys\nfrom math import *\nfrom collections import *\nfrom fractions import *\nfrom bisect import *\nfrom heapq import *\nfrom io import BytesIO, IOBase\n\ndef vsInput():\n\tsys.stdin = open('input.txt', 'r')\n\tsys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\n\ndef value():\n\treturn tuple(map(int, input().split()))\n\ndef array():\n\treturn [int(i) for i in input().split()]\n\ndef Int():\n\treturn int(input())\n\ndef Str():\n\treturn input()\n\ndef arrayS():\n\treturn [i for i in input().split()]\nn = Int()\npoints = sorted([abs(int(i)) for i in input().split()])\nans = 0\nfor i in range(n):\n\tpos = bisect_right(points, 2 * points[i])\n\tans += pos - i - 1\nprint(ans)\n", "import sys\nfrom bisect import bisect_right\ntry:\n\tsys.stdin = open('input.txt', 'r')\n\tsys.stdout = open('output.txt', 'w')\nexcept:\n\tpass\ninput = sys.stdin.readline\nT = 1\nwhile T:\n\tT -= 1\n\tn = int(input())\n\ta = list(map(int, input().split()))\n\ta = [abs(x) for x in a]\n\tans = 0\n\ta.sort()\n\tfor i in range(n):\n\t\tans += bisect_right(a, 2 * a[i]) - i - 1\n\tprint(ans)\n", "import bisect\nn = int(input())\nlist1 = list(map(int, input().split()))\nfor i in range(n):\n\tlist1[i] = abs(list1[i])\nlist1.sort()\nans = 0\nfor i in range(n):\n\tp = bisect.bisect_right(list1, 2 * list1[i]) - i - 1\n\tans += p\nprint(ans)\n", "import itertools\nimport bisect\nn = int(input())\narr = sorted(list(map(lambda x: abs(int(x)), input().strip().split())))\nanswer = 0\nfor i in range(n):\n\tanswer += bisect.bisect_right(arr, arr[i] * 2) - 1 - i\nprint(answer)\n", "from sys import setcheckinterval, stdin\nsetcheckinterval(1000)\niin = lambda : int(stdin.readline())\nlin = lambda : list(map(int, stdin.readline().split()))\nfrom bisect import bisect\nn = iin()\na = lin()\nfor i in range(n):\n\tif a[i] < 0:\n\t\ta[i] *= -1\na.sort()\nsol = 0\ni = 0\nwhile i < n:\n\tx = a[i]\n\tr = bisect(a, x + x)\n\tif r >= n or a[r] != 2 * x:\n\t\tr -= 1\n\tsol += r - i\n\ti += 1\nprint(sol)\n", "import bisect\nn = int(input())\nli = list(map(int, input().split()))\nfor i in range(n):\n\tif li[i] < 0:\n\t\tli[i] = -li[i]\nli.sort()\nans = 0\nfor (i, j) in enumerate(li[:-1]):\n\tt = bisect.bisect(li, 2 * j)\n\tans = ans + (t - i - 1)\nprint(ans)\n", "def bs(a, right, x):\n\t(l, r) = (-1, right)\n\twhile r - l > 1:\n\t\tm = l + (r - l) // 2\n\t\tif x <= 2 * a[m]:\n\t\t\tr = m\n\t\telse:\n\t\t\tl = m\n\treturn r\nn = int(input())\na = list(map(abs, map(int, input().split())))\na.sort()\nans = 0\nfor (i, elem) in enumerate(a):\n\tpos = bs(a, i, elem)\n\tans += i - pos\nprint(ans)\n", "n = int(input())\nA = list(map(int, input().split()))\nA = [abs(a) for a in A]\nA.sort()\nj = 0\nANS = 0\nfor i in range(n - 1):\n\twhile j < n - 1 and A[j + 1] - A[i] <= A[i]:\n\t\tj += 1\n\tANS += j - i\nprint(ANS)\n", "import sys\ninput = lambda : sys.stdin.readline().strip('\\r\\n')\nn = int(input())\na = sorted(list((abs(int(x)) for x in input().split())))\nl = 0\nr = 1\nans = 0\nwhile l < n:\n\twhile r < n and 2 * a[l] >= a[r]:\n\t\tr += 1\n\tans += r - l - 1\n\tl += 1\nprint(ans)\n", "from bisect import bisect_left, bisect_right\n\ndef answer(n, A):\n\tA.sort()\n\tcount = 0\n\tfor i in range(1, n):\n\t\tif A[i] <= 0:\n\t\t\tindex = bisect_left(A, 2 * A[i])\n\t\t\tcount += i - index\n\t\telse:\n\t\t\tindex1 = bisect_left(A, -2 * A[i])\n\t\t\tindex2 = bisect_right(A, -1 * ((A[i] + 1) // 2))\n\t\t\tindex3 = bisect_left(A, (A[i] + 1) // 2)\n\t\t\tcount += index2 - index1 + i - index3\n\treturn count\nn = int(input())\narr = list(map(int, input().split()))\nprint(answer(n, arr))\n", "import bisect\nn = int(input())\narr = []\nl = input().split()\nli = [int(i) for i in l]\nfor i in li:\n\tarr.append(abs(i))\narr.sort()\nans = 0\nfor i in range(n):\n\tans += bisect.bisect_right(arr, 2 * arr[i]) - (i + 1)\nprint(ans)\n", "import os\nimport sys\nfrom io import BytesIO, IOBase\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\nn = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tif l[i] < 0:\n\t\tl[i] *= -1\nl.sort()\nst = 0\nend = 1\nans = 0\nwhile end < n:\n\tif l[end] <= 2 * l[st]:\n\t\tans += end - st\n\t\tend += 1\n\telse:\n\t\tst += 1\n\tif end == st:\n\t\tend += 1\nprint(ans)\n", "import sys, heapq, bisect\nfrom collections import deque, defaultdict\nprintn = lambda x: sys.stdout.write(x)\ninn = lambda : int(input())\ninl = lambda : list(map(int, input().split()))\ninm = lambda : map(int, input().split())\nDBG = True and False\n\ndef ddprint(x):\n\tif DBG:\n\t\tprint(x)\nn = inn()\na = inl()\na.sort()\nddprint(a)\nsum = 0\nfor i in range(n - 1):\n\tai = a[i]\n\tif ai < 0:\n\t\tp1 = bisect.bisect_right(a, ai // 2)\n\t\tp2 = bisect.bisect_left(a, (-ai + 1) // 2)\n\t\tp3 = bisect.bisect_right(a, -ai * 2)\n\t\tddprint('i {} ai {} p123 {} {} {}'.format(i, ai, p1, p2, p3))\n\t\tsum += p1 - i - 1 + (p3 - p2)\n\telif ai > 0:\n\t\tp5 = bisect.bisect_right(a, ai * 2)\n\t\tddprint('i {} ai {} p45 {} {}'.format(i, ai, i, p5))\n\t\tsum += p5 - i - 1\nprint(sum)\n", "from bisect import bisect_left\nn = int(input())\n\ndef process():\n\tresult = 0\n\ttmp = 0\n\ta = list(map(int, input().split()))\n\tfor i in range(n):\n\t\ta[i] = abs(a[i])\n\ta.sort()\n\tfor i in range(n):\n\t\tx = a[i] // 2\n\t\tif a[i] % 2 == 1:\n\t\t\tx += 1\n\t\ttmp = bisect_left(a, x)\n\t\tif a[tmp] < x:\n\t\t\tcontinue\n\t\tresult += i - tmp\n\tprint(result)\nprocess()\n", "from bisect import bisect\nn = int(input())\na = [abs(int(i)) for i in input().split(' ')]\nb = sorted(a)\nc = 0\nfor l in range(n):\n\tr = bisect(b, 2 * b[l])\n\tc += r - l - 1\nprint(c)\n", "def main():\n\timport sys\n\tinput = sys.stdin.readline\n\n\tdef va(x):\n\t\treturn abs(int(x))\n\tn = int(input())\n\tpoints = list(map(va, input().split()))\n\tpoints.sort()\n\n\tdef dichotomie(fin, valeur, debut):\n\t\ta = 0\n\t\tb = fin\n\t\twhile b - a > 1:\n\t\t\tc = (a + b) // 2\n\t\t\tif points[c] >= valeur:\n\t\t\t\tb = c\n\t\t\telse:\n\t\t\t\ta = c\n\t\tif points[a] >= valeur:\n\t\t\treturn a\n\t\telse:\n\t\t\treturn b\n\tsomme = 0\n\ta = 0\n\tfor i in range(len(points)):\n\t\tvaleur = points[i]\n\t\ta = dichotomie(i, valeur / 2, a)\n\t\tsomme += i - a\n\tprint(somme)\nmain()\n", "import bisect\nn = int(input())\na = list(map(int, input().split()))\na = [abs(i) for i in a]\na.sort()\nc = 0\nfor i in range(len(a) - 1):\n\tind = bisect.bisect_right(a, 2 * a[i], i, len(a))\n\tc += ind - i\n\tif ind >= len(a) or a[ind] != 2 * a[i]:\n\t\tc -= 1\nprint(c)\n", "import sys, os, io\n\ndef rs():\n\treturn sys.stdin.readline().rstrip()\n\ndef ri():\n\treturn int(sys.stdin.readline())\n\ndef ria():\n\treturn list(map(int, sys.stdin.readline().split()))\n\ndef ws(s):\n\tsys.stdout.write(s + '\\n')\n\ndef wi(n):\n\tsys.stdout.write(str(n) + '\\n')\n\ndef wia(a):\n\tsys.stdout.write(' '.join([str(x) for x in a]) + '\\n')\nimport math, datetime, functools, itertools, operator, bisect, fractions, statistics\nfrom collections import deque, defaultdict, OrderedDict, Counter\nfrom fractions import Fraction\nfrom decimal import Decimal\nfrom sys import stdout\nfrom heapq import heappush, heappop, heapify, _heapify_max, _heappop_max\n\ndef main():\n\tstarttime = datetime.datetime.now()\n\tif os.path.exists('input.txt'):\n\t\tsys.stdin = open('input.txt', 'r')\n\t\tsys.stdout = open('output.txt', 'w')\n\tfor _ in range(1):\n\t\tn = ri()\n\t\ta = ria()\n\t\tfor i in range(n):\n\t\t\ta[i] = abs(a[i])\n\t\tans = 0\n\t\ta = sorted(a)\n\t\tfor i in range(n):\n\t\t\tans += i - bisect.bisect_left(a, math.ceil(a[i] / 2))\n\t\tprint(ans)\n\tendtime = datetime.datetime.now()\n\ttime = (endtime - starttime).total_seconds() * 1000\n\tif os.path.exists('input.txt'):\n\t\tprint('Time:', time, 'ms')\n\nclass FastReader(io.IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, fd, chunk_size=1024 * 8):\n\t\tself._fd = fd\n\t\tself._chunk_size = chunk_size\n\t\tself.buffer = io.BytesIO()\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self, size=-1):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\nclass FastWriter(io.IOBase):\n\n\tdef __init__(self, fd):\n\t\tself._fd = fd\n\t\tself.buffer = io.BytesIO()\n\t\tself.write = self.buffer.write\n\n\tdef flush(self):\n\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass FastStdin(io.IOBase):\n\n\tdef __init__(self, fd=0):\n\t\tself.buffer = FastReader(fd)\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n\nclass FastStdout(io.IOBase):\n\n\tdef __init__(self, fd=1):\n\t\tself.buffer = FastWriter(fd)\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.flush = self.buffer.flush\nsys.stdin = FastStdin()\nsys.stdout = FastStdout()\nmain()\n", "n = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\ns = 0\nfor i in range(n - 1):\n\tj = n - 1\n\tv = l[i] * 2\n\tco = i\n\tcin = -2\n\tpin = -1\n\twhile cin != pin:\n\t\tpin = cin\n\t\tcin = (i + j) // 2\n\t\tif l[cin] > v:\n\t\t\tj = cin\n\t\telse:\n\t\t\ti = cin\n\tif l[cin + 1] <= v:\n\t\tcin += 1\n\ts += cin - co\nprint(s)\n", "import sys\nfrom collections import defaultdict as dc\nfrom collections import Counter\nfrom bisect import bisect_right, bisect_left\nimport math\nfrom operator import itemgetter\nfrom heapq import heapify, heappop, heappush\nn = int(input())\nl = list(map(int, input().split()))\nl = [abs(i) for i in l]\nl.sort()\nc = 0\nfor i in range(n):\n\tj = bisect_right(l, 2 * l[i])\n\tc += j - 1 - i\nprint(c)\n", "from bisect import bisect_left\nn = int(input())\na = sorted(map(abs, map(int, input().split())))\nr = 0\nfor (i, v) in enumerate(a):\n\tt = bisect_left(a, (v + 1) // 2)\n\tr += i - t\nprint(r)\n", "n = int(input())\nl1 = list(map(int, input().split()))\nl2 = []\nfor i in range(0, n):\n\tif l1[i] != 0:\n\t\tl2.append(abs(l1[i]))\nimport bisect\nl2.sort()\nans = 0\nfor i in range(0, len(l2)):\n\tx = bisect.bisect_right(l2, 2 * l2[i], 0, len(l2))\n\tans += x - i - 1\nprint(ans)\n", "n = int(input())\ns = list(sorted([abs(i) for i in map(int, input().split())]))\nl = 0\nr = 1\nans = 0\nwhile l < n - 1 or r < n:\n\twhile r < n and s[l] * 2 >= s[r]:\n\t\tr += 1\n\tans += r - l - 1\n\tl += 1\nprint(ans)\n", "n = int(input())\nlst = [int(i) for i in input().split()]\nb = [abs(elem) for elem in lst]\nb.sort()\n(j, result) = (0, 0)\nfor i in range(n - 1):\n\twhile j < n - 1 and b[j + 1] - b[i] <= b[i]:\n\t\tj += 1\n\tresult += j - i\nprint(result)\n", "n = int(input())\nlis = sorted(map(abs, map(int, input().split())))\nc = 0\ni = j = 0\nwhile i < n:\n\twhile j < n and 2 * lis[i] >= lis[j]:\n\t\tj += 1\n\ti += 1\n\tc += j - i\nprint(c)\n", "import sys\ninput = sys.stdin.buffer.readline\n\ndef solution():\n\tn = int(input())\n\tl = list(map(int, input().split()))\n\tl = [abs(x) for x in l]\n\tl.sort()\n\ti = 0\n\tj = 0\n\tans = 0\n\twhile i < n:\n\t\twhile 2 * l[j] < l[i]:\n\t\t\tj += 1\n\t\tans += i - j\n\t\ti += 1\n\tprint(ans)\nsolution()\n", "from sys import stdin, stdout\nfrom bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import *\nfrom random import *\nfrom itertools import permutations\ninput = stdin.readline\nprin = stdout.write\nfrom random import sample\nfrom collections import Counter, deque\nfrom fractions import *\nfrom math import sqrt, ceil, log2, gcd, cos, pi, floor\nfrom copy import deepcopy\nmod = 10 ** 9 + 7\nmod2 = 998244353\n\ndef ps(n):\n\tcp = 0\n\tlk = 0\n\tarr = {}\n\tlk = 0\n\tap = n\n\tcc = 0\n\twhile n % 2 == 0:\n\t\tn = n // 2\n\t\tcc = 1\n\tif cc == 1:\n\t\tlk += 1\n\tfor ps in range(3, ceil(sqrt(n)) + 1, 2):\n\t\tcc = 0\n\t\twhile n % ps == 0:\n\t\t\tn = n // ps\n\t\t\tcc = 1\n\t\tlk += 1 if cc == 1 else 0\n\tif n != 1:\n\t\tlk += 1\n\tif lk == 1:\n\t\treturn False\n\treturn True\n\ndef gcd(x, y):\n\twhile y:\n\t\t(x, y) = (y, x % y)\n\treturn x\n\ndef factorials(n, r):\n\tslr = n\n\tdpr = r\n\tqlr = 1\n\tqs = 1\n\tmod = 10 ** 9 + 7\n\tfor ip in range(n - r + 1, n):\n\t\tqlr = qlr * ip % mod\n\tfor ij in range(1, r):\n\t\tqs = qs * ij % mod\n\tans = qlr * modInverse(qs) % mod\n\treturn ans\n\ndef modInverse(b):\n\tqr = 10 ** 9 + 7\n\treturn pow(b, qr - 2, qr)\nfrom types import GeneratorType\n\ndef iterative(f, stack=[]):\n\n\tdef wrapped_func(*args, **kwargs):\n\t\tif stack:\n\t\t\treturn f(*args, **kwargs)\n\t\tto = f(*args, **kwargs)\n\t\twhile True:\n\t\t\tif type(to) is GeneratorType:\n\t\t\t\tstack.append(to)\n\t\t\t\tto = next(to)\n\t\t\t\tcontinue\n\t\t\tstack.pop()\n\t\t\tif not stack:\n\t\t\t\tbreak\n\t\t\tto = stack[-1].send(to)\n\t\treturn to\n\treturn wrapped_func\n\ndef power(arr):\n\tlistrep = arr\n\tsubsets = []\n\tfor i in range(2 ** len(listrep)):\n\t\tsubset = []\n\t\tfor k in range(len(listrep)):\n\t\t\tif i & 1 << k:\n\t\t\t\tsubset.append(listrep[k])\n\t\tsubsets.append(subset)\n\treturn subsets\n\ndef pda(n):\n\tlist = []\n\tsu = 0\n\tfor i in range(1, int(sqrt(n) + 1)):\n\t\tif n % i == 0:\n\t\t\tif n // i == i:\n\t\t\t\tlist.append(i)\n\t\t\t\tsu += i\n\t\t\telse:\n\t\t\t\tlist.append(n // i)\n\t\t\t\tlist.append(i)\n\t\t\t\tsu += i\n\t\t\t\tsu += n // i\n\treturn su\n\ndef dis(xa, ya, xb, yb):\n\treturn sqrt((xa - xb) ** 2 + (ya - yb) ** 2)\n\ndef ii():\n\treturn int(input())\n\ndef ilist():\n\treturn [int(x) for x in input().strip().split()]\n\ndef islist():\n\treturn list(map(str, input().split().rstrip()))\n\ndef inp():\n\treturn input().strip()\n\ndef google(test):\n\treturn 'Case #' + str(test) + ': '\n\ndef overlap(x1, y1, x2, y2):\n\tif x2 > y1:\n\t\treturn y1 - x2\n\tif y1 > y2:\n\t\treturn y2 - x2\n\treturn y1 - x2\n\ndef dist(x1, y1, x2, y2):\n\treturn sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\ndef sieve(n):\n\tprime = [True for i in range(n + 1)]\n\tp = 2\n\twhile p * p <= n:\n\t\tif prime[p] == True:\n\t\t\tfor i in range(p * 2, n + 1, p):\n\t\t\t\tprime[i] = False\n\t\tp += 1\n\tprime[0] = False\n\tprime[1] = False\n\tans = []\n\tfor i in range(1, n + 1):\n\t\tif prime[i]:\n\t\t\tans.append(i)\n\treturn ans\n\ndef prod(arr):\n\tn = len(arr)\n\tk = 1\n\tfor j in range(n):\n\t\tk *= arr[j]\n\treturn k\n\ndef SumOfDigits(s):\n\tsu = 0\n\twhile s:\n\t\tsu += s % 10\n\t\ts = s // 10\n\treturn su\n\ndef std():\n\treturn stdout.flush()\n\ndef finds(s):\n\tatt = 0\n\ti = 1\n\twhile i < len(s):\n\t\tatt = int(s[:i])\n\t\tj = i\n\t\tcc = 0\n\t\twhile j < len(s):\n\t\t\tatt += 1\n\t\t\tsk = att\n\t\t\tnews = str(sk)\n\t\t\trr = len(news)\n\t\t\tif news == s[j:j + rr]:\n\t\t\t\tj += rr\n\t\t\telse:\n\t\t\t\tcc = 1\n\t\t\t\tbreak\n\t\tif cc == 0:\n\t\t\treturn True\n\t\ti += 1\n\treturn False\narr = []\nfor i in range(1, 10001):\n\ts = str(i)\n\tj = i\n\twhile len(s) <= 7:\n\t\tj += 1\n\t\ts += str(j)\n\t\tarr.append(int(s))\narr.sort()\n\ndef subs(arr):\n\tres = set()\n\tpre = {0}\n\tfor x in arr:\n\t\tpre = {x | y for y in pre} | {x}\n\t\tres |= pre\n\treturn len(res)\n\ndef sl(n):\n\treturn n * (n + 1) // 2\nt = 1\nfor pl in range(t):\n\tn = ii()\n\tarr = ilist()\n\tpos = {}\n\tneg = {}\n\tfor i in range(n):\n\t\tif arr[i] < 0:\n\t\t\tif -1 * arr[i] in neg:\n\t\t\t\tneg[-1 * arr[i]] += 1\n\t\t\telse:\n\t\t\t\tneg[-1 * arr[i]] = 1\n\t\telif arr[i] in pos:\n\t\t\tpos[arr[i]] += 1\n\t\telse:\n\t\t\tpos[arr[i]] = 1\n\tfor i in range(n):\n\t\tarr[i] = abs(arr[i])\n\tarr.sort()\n\tans = 0\n\tchecked = set()\n\tfor i in range(n):\n\t\tif arr[i] not in checked:\n\t\t\tant = br(arr, 2 * arr[i], 0, n)\n\t\t\tbnt = br(arr, arr[i], 0, n)\n\t\t\tco = 0\n\t\t\tif arr[i] in neg:\n\t\t\t\tco += neg[arr[i]]\n\t\t\tif arr[i] in pos:\n\t\t\t\tco += pos[arr[i]]\n\t\t\tans += (ant - bnt) * co\n\t\t\tchecked.add(arr[i])\n\tfor tt in pos:\n\t\tif tt in neg:\n\t\t\tans += pos[tt] * neg[tt]\n\tprint(ans)\n", "n = int(input())\na = list(map(lambda x: abs(int(x)), input().split()))\na.sort()\nhead = 0\ntail = 1\nresult = 0\nwhile tail <= n:\n\twhile tail < n and a[head] * 2 >= a[tail]:\n\t\ttail += 1\n\tresult += tail - 1 - head\n\thead += 1\n\tif tail == head:\n\t\ttail += 1\nprint(result)\n", "import copy\nn = int(input())\nl = list(map(int, input().split()))\ni = 0\nwhile i < n:\n\tif l[i] == 0:\n\t\tl = l[:i] + l[i + 1:]\n\t\tn -= 1\n\ti += 1\np = n\nl.sort()\nfor i in range(n):\n\tif l[i] > 0:\n\t\tp = i\n\t\tbreak\npos = copy.deepcopy(l[p:])\nneg = copy.deepcopy(l[:p])\ncount = 0\ni = 0\nj = 0\nwhile i < n - p:\n\twhile j < n - p and pos[j] <= 2 * pos[i]:\n\t\tj += 1\n\tcount += j - i - 1\n\ti += 1\ni = p - 1\nj = p - 1\nwhile i > 0:\n\twhile j >= 0 and neg[j] >= 2 * neg[i]:\n\t\tj -= 1\n\tcount += i - j - 1\n\ti -= 1\ni = 0\nj = p - 1\nk = p - 1\nwhile i < n - p:\n\twhile j >= 0 and abs(neg[j]) <= 2 * pos[i]:\n\t\tj -= 1\n\twhile k >= 0 and abs(neg[k]) < pos[i] / 2:\n\t\tk -= 1\n\tcount += k - j\n\ti += 1\nprint(count)\n", "import bisect\nn = int(input())\na = [abs(int(o)) for o in input().split()]\na = sorted(a)\nans = 0\nfor i in range(n):\n\tlol = 2 * a[i]\n\tind = bisect.bisect(a, lol)\n\tans += ind - i - 1\nprint(ans)\n", "from bisect import bisect_right\na = int(input())\nz = list(map(int, input().split()))\nfor i in range(len(z)):\n\tz[i] = abs(z[i])\nz.sort()\nx = 0\ntotal = 0\nfor i in range(len(z)):\n\tx = bisect_right(z, 2 * z[i])\n\tx -= i + 1\n\ttotal += x\nprint(total)\n", "from sys import *\nfrom bisect import *\nN = int(input())\npos = []\nneg = []\nA = list(map(int, stdin.readline().split()))\nfor a in A:\n\tif a > 0:\n\t\tpos += [a]\n\telse:\n\t\tneg += [-a]\npos.sort()\nneg.sort()\nans = 0\nfor (i, x) in enumerate(pos):\n\tans += max(0, bisect_right(pos, x * 2) - i - 1)\n\tl = bisect_left(neg, x)\n\tr = bisect_right(neg, x * 2)\n\tans += max(0, r - l)\nfor (i, x) in enumerate(neg):\n\tans += max(0, bisect_right(neg, x * 2) - i - 1)\n\tl = bisect_right(pos, x)\n\tr = bisect_right(pos, x * 2)\n\tans += max(0, r - l)\nprint(ans)\n", "from collections import deque\nn = int(input().strip())\nnums = list(map(int, input().strip().split()))\nnums = sorted([abs(num) for num in nums], reverse=True)\nres = 0\nmax_index = 0\ncurr_index = 1\nfor curr_index in range(1, n):\n\twhile nums[curr_index] * 2 < nums[max_index]:\n\t\tmax_index += 1\n\tres += curr_index - max_index\nprint(res)\n", "num = int(input())\ndata = [abs(int(i)) for i in input().split()]\ndata.sort()\n\ndef bins(a, b, n):\n\tif a == b:\n\t\tif data[a] <= n:\n\t\t\treturn a + 1\n\t\telse:\n\t\t\treturn a\n\telse:\n\t\tm = (a + b) // 2\n\t\tif data[m] <= n:\n\t\t\treturn bins(m + 1, b, n)\n\t\telse:\n\t\t\treturn bins(a, m, n)\nsum = 0\nind = 0\nfor i in range(num):\n\twhile ind < num and data[ind] <= 2 * data[i]:\n\t\tind += 1\n\tsum += ind - i - 1\nprint(sum)\n", "def aTaleOfTwoLands(n, cor):\n\tz = 0\n\tsum = 0\n\tfor i in range(n):\n\t\tmax = 2 * cor[i]\n\t\twhile z < n and cor[z] <= max:\n\t\t\tz = z + 1\n\t\tsum = sum + z - i - 1\n\tprint(sum)\n\ndef main():\n\tn = int(input())\n\tcor = sorted([abs(int(i)) for i in input().split()])\n\taTaleOfTwoLands(n, cor)\nmain()\n", "from collections import defaultdict as dd\nimport math\n\ndef nn():\n\treturn int(input())\n\ndef li():\n\treturn list(input())\n\ndef mi():\n\treturn list(map(int, input().split()))\n\ndef lm():\n\treturn list(map(int, input().split()))\nn = nn()\nvals = lm()\navals = [abs(v) for v in vals]\navals.sort()\ntotal = 0\nstart = 0\nend = 1\nwhile end < n:\n\tif 2 * avals[start] >= avals[end]:\n\t\tend += 1\n\telse:\n\t\ttotal = total + max(0, end - start - 1)\n\t\tstart += 1\nnum = end - start\ntotal += num * (num - 1) // 2\nprint(total)\n", "n = int(input())\na = list(map(int, input().split()))\ncount = 0\n(i, j) = (0, 0)\na = list(map(abs, a))\na.sort()\nwhile i < n and j < n:\n\ty = a[i]\n\tx = a[j]\n\tif x <= 2 * y:\n\t\tif j < n - 1:\n\t\t\tj = j + 1\n\t\telse:\n\t\t\tcount = count + (j - i)\n\t\t\ti = i + 1\n\telse:\n\t\tcount = count + (j - 1 - i)\n\t\ti = i + 1\nprint(count)\n", "n = int(input())\na = sorted(list(map(int, input().split())), key=lambda x: abs(x))\nr = 0\nans = 0\nfor i in range(n):\n\twhile r < n and abs(a[r]) <= abs(a[i] * 2):\n\t\tr += 1\n\tans += r - i - 1\nprint(ans)\n", "N = int(input())\nList = list(map(int, input().split()))\nfor i in range(len(List)):\n\tList[i] = abs(List[i])\nList.sort()\nl = len(List) - 2\nr = len(List) - 1\nanswer = 0\nwhile l > -1:\n\twhile 2 * List[l] >= List[r] and l > -1:\n\t\tl -= 1\n\tif l >= 0:\n\t\tanswer += r - 1 - l\n\t\tr -= 1\n\tif l == -1:\n\t\tanswer += r * (r + 1) / 2\n\t\tbreak\nprint(int(answer))\n", "from sys import stdin, setrecursionlimit\nfrom bisect import bisect_right\nimport math\nsetrecursionlimit(15000)\nn = int(stdin.readline().strip())\narr = list(map(int, stdin.readline().split()))\nfor i in range(n):\n\tarr[i] = abs(arr[i])\narr.sort()\ncount = 0\nfor i in range(n):\n\tindex = bisect_right(arr, arr[i] * 2)\n\tcount += index - i - 1\nprint(count)\n", "from bisect import *\nn = int(input())\nl = [abs(int(i)) for i in input().split()]\nl.sort()\nans = 0\nfor i in range(n):\n\tx = 0\n\tif l[i] % 2 == 0:\n\t\tx = l[i] // 2\n\telse:\n\t\tx = l[i] // 2 + 1\n\tind = bisect_left(l, x)\n\tans += i - ind\nprint(ans)\n", "from bisect import bisect_right as br\nseq = lambda : list(map(abs, map(int, input().strip().split())))\ninp = lambda : int(input())\nmul = lambda : map(int, input().strip().split())\nn = inp()\nt = seq()\nt.sort()\nct = 0\nfor i in range(n):\n\tind = br(t, 2 * t[i])\n\tct += ind - i - 1\nprint(ct)\n", "import sys\nfrom bisect import *\nrl = lambda : list(map(int, sys.stdin.readline().split()))\nn = int(input())\nA = rl()\nA = sorted([abs(x) for x in A])\nans = 0\nfor i in range(n):\n\tidx = bisect_right(A, 2 * A[i])\n\tans += abs(idx - i - 1)\nprint(ans)\n", "import bisect\nimport sys\nn = int(sys.stdin.readline())\na = [abs(int(x)) for x in sys.stdin.readline().split()]\na.sort()\nans = 0\nfor i in range(n):\n\tadd = bisect.bisect(a, a[i] * 2) - i - 1\n\tans += add\nsys.stdout.write(str(ans))\n", "from sys import stdin, stdout\nimport math, sys, heapq\nfrom itertools import permutations, combinations\nfrom collections import defaultdict, deque, OrderedDict\nfrom os import path\nimport random\nimport bisect as bi\n\ndef yes():\n\tprint('YES')\n\ndef no():\n\tprint('NO')\nif path.exists('input.txt'):\n\tsys.stdin = open('input.txt', 'r')\n\tsys.stdout = open('output.txt', 'w')\n\n\tdef I():\n\t\treturn int(input())\n\n\tdef In():\n\t\treturn map(int, input().split())\nelse:\n\n\tdef I():\n\t\treturn int(stdin.readline())\n\n\tdef In():\n\t\treturn map(int, stdin.readline().split())\n\ndef dict(a):\n\td = {}\n\tfor x in a:\n\t\tif d.get(x, -1) != -1:\n\t\t\td[x] += 1\n\t\telse:\n\t\t\td[x] = 1\n\treturn d\n\ndef find_gt(a, x):\n\ti = bi.bisect_right(a, x)\n\tif i != len(a):\n\t\treturn i - 1\n\telse:\n\t\treturn len(a) - 1\n\ndef main():\n\ttry:\n\t\tn = I()\n\t\tl = list(In())\n\t\tfor i in range(n):\n\t\t\tl[i] = abs(l[i])\n\t\tl.sort()\n\t\tans = 0\n\t\tfor x in range(n):\n\t\t\tpos = find_gt(l, 2 * l[x])\n\t\t\tans += pos - x\n\t\tprint(ans)\n\texcept:\n\t\tpass\nM = 998244353\nP = 1000000007\nfor _ in range(1):\n\tmain()\n", "import math\nn = int(input())\nli = sorted([*map(lambda x: abs(int(x)), input().split())])\nl = 0\nr = 1\np = 0\ntotal = 0\nwhile r < n or l != r:\n\tif r == l:\n\t\tr += 1\n\t\tp = 0\n\tif r <= n - 1 and li[r] - li[l] <= li[l]:\n\t\tr += 1\n\t\tp += 1\n\telse:\n\t\tl += 1\n\t\ttotal += p if p >= 0 else 0\n\t\tp -= 1\nprint(total)\n", "import bisect\nN = int(input())\nA = [abs(a) for a in map(int, input().split())]\nA.sort()\nans = 0\nfor i in range(N):\n\tyi = bisect.bisect_right(A, A[i] * 2)\n\tif yi > i:\n\t\tans += yi - i - 1\nprint(ans)\n", "import bisect as bs\nt = int(input())\nit = list(map(int, input().split()))\ntt = []\ns = {}\nfor i in it:\n\ttry:\n\t\ts[abs(i)] += 1\n\texcept:\n\t\ts[abs(i)] = 1\n\t\ttt.append(abs(i))\ntt.sort()\naa = [s[tt[0]]]\nsu = 0\nfor i in tt[1:]:\n\taa.append(aa[-1] + s[i])\nfor i in range(len(tt)):\n\tk = tt[i]\n\tind = bs.bisect_left(tt, 2 * k + 1)\n\tsu += (aa[ind - 1] - aa[i]) * s[k] + (s[k] - 1)\nprint(su)\n", "n = int(input())\na = list(map(int, input().split()))\nimport math\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\na.append(0)\nj = 1\ns = 0\nfor i in range(n):\n\ttem = a[i]\n\twhile a[j] <= 2 * tem and j <= n - 1:\n\t\tj += 1\n\ts += j - i - 1\nprint(s)\n", "import os\nimport sys\nfrom io import BytesIO, IOBase\nimport heapq as h\nfrom bisect import bisect_left, bisect_right\nfrom types import GeneratorType\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\timport os\n\t\tself.os = os\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tself.os.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\nfrom collections import defaultdict as dd, deque as dq\nimport math, string\n\ndef getInts():\n\treturn [int(s) for s in input().split()]\n\ndef getInt():\n\treturn int(input())\n\ndef getStrs():\n\treturn [s for s in input().split()]\n\ndef getStr():\n\treturn input()\n\ndef listStr():\n\treturn list(input())\nMOD = 10 ** 9 + 7\n\ndef solve():\n\tN = getInt()\n\tA = sorted([abs(a) for a in getInts()])\n\ti = 0\n\tj = 1\n\tans = 0\n\twhile i < N:\n\t\twhile j < N and A[j] <= 2 * A[i]:\n\t\t\tj += 1\n\t\tans += j - i - 1\n\t\ti += 1\n\treturn ans\nprint(solve())\n", "import sys\ninput = sys.stdin.readline\nn = int(input())\nl = [abs(int(i)) for i in input().split()]\nl = sorted(l)\np = 0\nq = 1\nans = 0\nwhile q < n:\n\twhile l[p] < l[q] / 2:\n\t\tp += 1\n\tans += q - p\n\tq += 1\nprint(ans)\n", "from bisect import bisect\nN = int(input())\ns = [int(x) for x in input().split()]\nans = 0\nfor i in range(0, len(s)):\n\ts[i] = abs(s[i])\nL = sorted(s)\nfor i in range(0, len(L)):\n\tt = bisect(L, 2 * L[i])\n\tans = ans + t - i - 1\nprint(ans)\n", "import bisect\nn = int(input())\nL = list(map(abs, map(int, input().split())))\nL.sort()\ncount = 0\nflg = 0\nfor i in range(n):\n\tj = bisect.bisect_left(L, 2 * L[i] + 1)\n\tif j < n:\n\t\tcount += j - 1 - i\n\telse:\n\t\tcount += (n - i - 1 + 1) * (n - i - 1) / 2\n\t\tbreak\nprint(int(count))\n", "n = int(input())\narr = list(map(lambda x: abs(int(x)), input().split()))\narr.sort()\nans = 0\ni = 0\nfor j in range(n):\n\twhile arr[i] * 2 < arr[j]:\n\t\ti += 1\n\tans += j - i\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\na = list(map(abs, a))\na.sort()\na.append(10 ** 10)\nlow = 0\nhigh = 0\ntot = 0\nwhile low < n:\n\tif a[high] <= 2 * a[low]:\n\t\thigh += 1\n\telse:\n\t\ttot += high - low - 1\n\t\tlow += 1\nprint(tot)\n", "import bisect\nn = int(input())\narr = [abs(int(x)) for x in input().split()]\narr.sort()\nl = 0\nfor i in range(n - 1):\n\tvar = bisect.bisect_right(arr, 2 * arr[i])\n\tl += var - i - 1\nprint(l)\n", "n = int(input())\narr = [abs(int(i)) for i in input().split(' ')]\narr.sort()\nans = 0\nj = 0\nfor i in range(n):\n\tx = arr[i]\n\twhile j < n:\n\t\ty = arr[j]\n\t\tif abs(x - y) <= abs(x) <= x + y and abs(x - y) <= abs(y) <= x + y:\n\t\t\tj += 1\n\t\telse:\n\t\t\tbreak\n\tans += j - i - 1\nprint(ans)\n", "import sys\ninput = sys.stdin.readline\nfrom math import *\nn = int(input())\n\ndef can(a, b):\n\tm1 = max(abs(a), abs(b))\n\tm2 = min(abs(a), abs(b))\n\tp = abs(a - b)\n\tq = abs(a + b)\n\tif q > p:\n\t\t(p, q) = (q, p)\n\tif q <= m2 <= m1 <= p:\n\t\treturn 1\n\treturn 0\na = [int(x) for x in input().split()]\nb = []\nfor i in a:\n\tb.append(abs(i))\na = b\na.sort()\nn = len(a)\nc = 0\nfor i in range(n):\n\tl = i + 1\n\tr = n - 1\n\tans = i\n\twhile l <= r:\n\t\tmid = l + (r - l) // 2\n\t\tif can(a[i], a[mid]):\n\t\t\tl = mid + 1\n\t\t\tans = mid\n\t\telse:\n\t\t\tr = mid - 1\n\tc += ans - i\nprint(c)\n", "n = int(input())\nls = list(map(int, input().split()))\nls = [abs(i) for i in ls]\nls.sort()\ni = 0\nj = 1\nres = []\ntry:\n\twhile True:\n\t\twhile ls[j] <= 2 * ls[i]:\n\t\t\tj += 1\n\t\tres.append(j - i - 1)\n\t\ti += 1\nexcept:\n\twhile i != n:\n\t\tres.append(j - i - 1)\n\t\ti += 1\nprint(sum(res))\n", "import sys, os\nimport bisect\nf = lambda : list(map(int, input().split()))\nif 'local' in os.environ:\n\tsys.stdin = open('./input.txt', 'r')\n\ndef solve():\n\tn = f()[0]\n\ta = f()\n\ta = [abs(i) for i in a]\n\ta = sorted(a)\n\tans = 0\n\tfor i in range(n):\n\t\tans += bisect.bisect_right(a, a[i] * 2) - i - 1\n\tprint(ans)\nsolve()\n", "n = int(input())\narr = sorted(list(map(lambda x: abs(int(x)), input().split())), reverse=True)\ncount = 0\nr = 1\nfor i in range(len(arr)):\n\twhile r < n and arr[i] / 2 <= arr[r]:\n\t\tr += 1\n\tcount += r - i - 1\nprint(count)\n", "n = int(input())\na = list(map(abs, map(int, input().split())))\na.sort()\n(ans, l) = (0, 0)\nfor i in range(1, n):\n\twhile l < i and 2 * a[l] < a[i]:\n\t\tl += 1\n\tans += i - l\nprint(ans)\n", "from sys import stdin, stdout\nimport bisect as bs\nfor _ in range(1):\n\tn = int(stdin.readline())\n\ta = sorted(map(lambda x: abs(int(x)), stdin.readline().split()))\n\tans = 0\n\tfor i in range(n):\n\t\tpos = bs.bisect_left(a, 2 * a[i] + 1)\n\t\tpos -= 1\n\t\tans += pos - i\n\tprint(ans)\n", "n = int(input())\nA = sorted(map(abs, map(int, input().split())))\nj = 0\ncount = 0\nfor i in range(n - 1):\n\twhile j < n - 1 and A[j + 1] <= 2 * A[i]:\n\t\tj += 1\n\tcount += j - i\nprint(count)\n", "import math\nimport bisect as bs\nn = int(input())\na = list(map(int, input().split()))\na = list(set(a))\nn = len(a)\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\nans = 0\nfor i in range(n):\n\tk = bs.bisect_left(a, math.ceil(a[i] / 2))\n\tk = i - k\n\tans += k\nprint(ans)\n", "n = int(input())\na = [abs(int(i)) for i in input().split()]\na.sort()\ny = 0\nx = 0\nans = 0\nwhile x < n:\n\twhile y < n - 1 and a[x] * 2 >= a[y + 1]:\n\t\ty += 1\n\tans += y - x\n\tx += 1\nprint(ans)\n", "def main():\n\tn = int(input())\n\tarr = [int(i) for i in input().split()]\n\tnew_arr = sorted([abs(i) for i in arr])\n\tcount = 0\n\tj_ptr = 1\n\ti_ptr = 0\n\twhile i_ptr < n:\n\t\tx = new_arr[i_ptr]\n\t\twhile j_ptr < n:\n\t\t\tif new_arr[j_ptr] <= 2 * x:\n\t\t\t\tj_ptr += 1\n\t\t\telse:\n\t\t\t\tbreak\n\t\tcount += j_ptr - i_ptr - 1\n\t\ti_ptr += 1\n\tprint(count)\nmain()\n", "n = int(input())\nl = list(map(abs, list(map(int, input().split()))))\nl.sort()\nans = 0\ni = j = 0\nwhile i < n:\n\tz = l[i] * 2\n\twhile j < n and z >= l[j]:\n\t\tj += 1\n\tans += j - i - 1\n\ti += 1\nprint(ans)\n", "N = int(input())\nA = sorted([abs(int(a)) for a in input().split()])\ni = 0\nj = 1\nans = 0\nwhile j < N:\n\twhile j < N - 1 and A[j + 1] <= A[i] * 2:\n\t\tj += 1\n\tif A[j] <= A[i] * 2:\n\t\tans += j - i\n\ti += 1\n\tif j == i:\n\t\tj += 1\nprint(ans)\n", "import bisect\nn = int(input())\na = list(map(int, input().split()))\na = [abs(i) for i in a]\na.sort()\nans = 0\nfor i in range(len(a)):\n\tright = a[i] * 2\n\tans += bisect.bisect_right(a, right) - (i + 1)\nprint(ans)\n", "n = int(input())\na = [abs(int(i)) for i in input().split()]\na.sort()\nptr = 0\nans = 0\nfor x in range(1, len(a)):\n\tif a[x] - a[ptr] <= a[ptr]:\n\t\tans += x - ptr\n\telse:\n\t\twhile ptr != x:\n\t\t\tif a[x] - a[ptr] <= a[ptr]:\n\t\t\t\tans += x - ptr\n\t\t\t\tbreak\n\t\t\tptr += 1\nprint(ans)\n", "from bisect import bisect_left\n\ndef solve():\n\tN = int(input())\n\tA = [abs(int(k)) for k in input().split()]\n\tA.sort()\n\tans = 0\n\tfor i in range(N - 1):\n\t\tpos = bisect_left(A, 2 * A[i])\n\t\tif pos == N or A[pos] > 2 * A[i]:\n\t\t\tpos -= 1\n\t\tif pos < N - 1 and A[pos] == A[pos + 1]:\n\t\t\tpos += 1\n\t\tif pos > i:\n\t\t\tans += pos - i\n\tprint(ans)\nsolve()\n", "def he(i):\n\treturn abs(int(i))\nn = int(input())\narr = list(map(he, input().split(' ')))\narr.sort()\nans = 0\nj = 1\ni = 0\nwhile i < n and j < n:\n\tif i < j:\n\t\tif 2 * arr[i] >= arr[j]:\n\t\t\tans += j - i\n\t\t\tj += 1\n\t\telse:\n\t\t\ti += 1\n\tif i == j:\n\t\tj += 1\nprint(ans)\n", "import bisect\nn = int(input())\narr = [abs(int(x)) for x in input().split()]\narr.sort()\nprint(sum((bisect.bisect_right(arr, 2 * arr[x], 0, n) - x - 1 for x in range(0, n))))\n", "from bisect import bisect_left\nn = int(input())\na = [int(e) for e in input().split(' ')]\na.sort()\nans = 0\nfor (i, e) in enumerate(a):\n\tif e < 0:\n\t\tind = bisect_left(a, e / 2)\n\t\tif ind >= n:\n\t\t\tind = n - 1\n\t\tif a[ind] > e / 2:\n\t\t\tind -= 1\n\t\tans += ind - i\n\t\tind1 = bisect_left(a, -e / 2)\n\t\tif ind1 < n:\n\t\t\tind2 = bisect_left(a, -2 * e)\n\t\t\tif ind2 >= n:\n\t\t\t\tind2 = n - 1\n\t\t\tif a[ind2] > -2 * e:\n\t\t\t\tind2 -= 1\n\t\t\tans += ind2 - ind1 + 1\n\telif e > 0:\n\t\tind = bisect_left(a, 2 * e)\n\t\tif ind >= n:\n\t\t\tind = n - 1\n\t\tif a[ind] > 2 * e:\n\t\t\tind -= 1\n\t\tans += ind - i\nprint(ans)\n", "from bisect import bisect_left\n\ndef f(n, arr):\n\tans = 0\n\tfor (i, val) in enumerate(arr):\n\t\tj = bisect_left(arr, val * 2 + 0.1)\n\t\tans += j - 1 - i\n\treturn ans\n\ndef main():\n\tn = int(input())\n\tarr = sorted(list(map(lambda x: abs(int(x)), input().split())))\n\tprint(f(n, arr))\nmain()\n", "import bisect\nn = int(input(''))\na = list(map(int, input().split()))\nfor i in range(n):\n\tif a[i] < 0:\n\t\ta[i] = a[i] * -1\na.sort()\ncnt = 0\nfor i in range(n):\n\tif a[i] == 0:\n\t\tcnt += 0\n\telse:\n\t\tt = bisect.bisect_left(a, 2 * a[i] + 1) - 1\n\t\tcnt += t - i\nprint(cnt)\n", "from bisect import bisect_left\nnumber_of_choices = 0\nchoices = []\nresult = 0\n\ndef Input(number_of_choices, choices):\n\tnumber_of_choices = int(input())\n\tchoices = list(map(int, input().split()))\n\treturn (number_of_choices, choices)\n\ndef Process(number_of_choices, choices, result):\n\tfor index in range(number_of_choices):\n\t\tchoices[index] = abs(choices[index])\n\tchoices.sort()\n\tresult = 0\n\tfor index in range(number_of_choices):\n\t\tmedium = choices[index] // 2\n\t\tif choices[index] % 2 == 1:\n\t\t\tmedium += 1\n\t\tfound_index = bisect_left(choices, medium)\n\t\tif choices[found_index] < medium:\n\t\t\tcontinue\n\t\tresult += index - found_index\n\treturn (number_of_choices, choices, result)\n\ndef Output(result):\n\tprint(result)\n(number_of_choices, choices) = Input(number_of_choices, choices)\n(number_of_choices, choices, result) = Process(number_of_choices, choices, result)\nOutput(result)\n", "n = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\nj = 1\nj1 = 1\nc = 0\nx = 0\nfor i in range(0, n - 1):\n\twhile j < n:\n\t\tif l[j] <= 2 * l[i]:\n\t\t\tc += 1\n\t\t\tj += 1\n\t\telse:\n\t\t\tbreak\n\tx = x + c + j1 - i - 1\n\tc = 0\n\tj1 = j\nprint(x)\n", "import bisect\n\ndef solve(n, arr):\n\tarr = sorted([abs(a) for a in arr])\n\tres = 0\n\t(dposX, dpos2X) = ({}, {})\n\tfor x in arr:\n\t\tif x in dposX:\n\t\t\tposX = dposX[x]\n\t\ti = dposX[x] = bisect.bisect_left(arr, x)\n\t\tif 2 * x in dpos2X:\n\t\t\tpos2X = dpos2X[x]\n\t\tj = dpos2X[x] = bisect.bisect(arr, 2 * x)\n\t\tres += j - i - 1\n\tres -= len(arr) - len(set(arr))\n\treturn res\n\ndef test():\n\tfrom sys import stdin\n\tT = int(stdin.readline().strip())\n\tfor _ in range(T):\n\t\tn = int(stdin.readline().strip())\n\t\tarr = list(map(int, stdin.readline().strip().split()))\n\t\tprint(solve(n, arr))\n\ndef main():\n\tfrom sys import stdin\n\tn = int(stdin.readline().strip())\n\tarr = list(map(int, stdin.readline().strip().split()))\n\tprint(solve(n, arr))\nmain()\n", "n = int(input())\na = [abs(int(x)) for x in input().split()]\na.sort()\nct = 0\nj = 0\nsum = 0\nfor i in range(n):\n\twhile j < n and a[j] <= 2 * a[i]:\n\t\tct += 1\n\t\tj += 1\n\tsum += ct\nsum -= (n * n + n) // 2\nprint(sum)\n", "def bin(a, num, s, e, i):\n\tif s > e:\n\t\tif e <= i:\n\t\t\treturn i\n\t\telse:\n\t\t\treturn e\n\tmid = (s + e) // 2\n\tif a[mid] > num:\n\t\treturn bin(a, num, s, mid - 1, i)\n\telif a[mid] < num:\n\t\treturn bin(a, num, mid + 1, e, i)\n\telse:\n\t\treturn mid\nn = int(input())\na = [abs(int(x)) for x in input().split()]\na.sort()\nc = 0\ntemp = 1\nfor i in range(n):\n\tf = 1\n\tfor j in range(temp, n):\n\t\tif a[j] > 2 * a[i]:\n\t\t\ttemp = j - 1\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\ttemp = n - 1\n\tc += temp - i\nprint(c)\n", "import bisect, math\nN = int(input())\na = sorted([abs(int(val)) for val in input().split()])\ncounts = [0 for _ in range(len(set(a)))]\nindex = {}\nli = 0\nfor k in a:\n\tif k not in index:\n\t\tindex[k] = li\n\t\tli += 1\n\tcounts[index[k]] += 1\nfor i in range(1, len(counts)):\n\tcounts[i] += counts[i - 1]\ncounts.insert(0, 0)\nitems = list(index.keys())\n\ndef get_index(x):\n\ti = bisect.bisect_left(items, x)\n\tif items[i] == x:\n\t\ti += 1\n\treturn i\nc = 0\nfor q in set(a):\n\tcc = counts[get_index(q)] - counts[get_index(q) - 1]\n\tsc = counts[get_index(q - 1)] - counts[get_index((q - 1) // 2)]\n\tc += cc * sc + cc * (cc - 1) // 2\nprint(c)\n", "n = int(input(''))\nsu = 0\np = 1.2\nl = 1\nk = [abs(int(x)) for x in input('').split(' ')]\nk1 = sorted(k)\nkm = k1[-1]\nk1.append(2 * km + 1)\nfor j in range(n - 1):\n\ti = k1[j]\n\tif i == p:\n\t\tsu += l - j - 1\n\t\tcontinue\n\twhile k1[l] <= 2 * i and l < n:\n\t\tl += 1\n\tsu += l - j - 1\n\tp = i\nprint(su)\n", "n = int(input())\nar = list(map(int, input().split()))\nfor i in range(n):\n\tar[i] = abs(ar[i])\nar.sort()\nj = 1\nans = 0\nfor i in range(n):\n\twhile j < n and ar[j] <= 2 * ar[i]:\n\t\tj += 1\n\tans = ans + j - i - 1\nprint(ans)\n", "from functools import lru_cache\nimport collections\nimport math\nN = int(input())\narr = list(map(int, input('').split()))\narr = [abs(a) for a in arr if a != 0]\narr = sorted(arr)\nN = len(arr)\nans = 0\nidx = 1\ni = 0\nwhile i < N and idx < N:\n\tif arr[i] * 2 >= arr[idx]:\n\t\tans += idx - i\n\t\tidx += 1\n\telse:\n\t\ti += 1\n\tif idx >= N:\n\t\tbreak\nprint(ans)\n", "import math\nn = int(input())\na = input().split()\nfor i in range(n):\n\ta[i] = abs(int(a[i]))\na = sorted(a)\ns = 0\nfor i in range(1, n):\n\tif a[i - 1] * 2 < a[i]:\n\t\tcontinue\n\tl = 0\n\tr = i - 1\n\twhile r != l:\n\t\tsr = (r + l) // 2\n\t\tif a[sr] * 2 >= a[i]:\n\t\t\tr = sr\n\t\telse:\n\t\t\tl = sr + 1\n\ts += i - l\nprint(s)\n", "def main():\n\tfrom math import ceil\n\tfrom bisect import bisect_right, bisect_left\n\tn = int(input())\n\ta = sorted([abs(int(i)) for i in input().split()])\n\tans = 0\n\tfor i in range(n):\n\t\tl = bisect_left(a, ceil(a[i] / 2)) - 1\n\t\tr = bisect_right(a, a[i] * 2) - 1\n\t\tif l == -1 or a[l] * 2 < a[i]:\n\t\t\tl += 1\n\t\tif a[r] > a[i] * 2 or r == n:\n\t\t\tr -= 1\n\t\tif i > l and a[i] <= a[l] * 2:\n\t\t\tans += i - l\n\t\tif i < r and a[i] * 2 >= a[r]:\n\t\t\tans += r - i\n\tans //= 2\n\tprint(ans)\nmain()\n", "n = int(input())\ns = input()\nns = list(map(lambda x: abs(int(x)), s.split()))\nns.sort()\ni = 0\nj = 1\nsum = 0\nwhile True:\n\tt = 0\n\twhile ns[j] <= ns[i] * 2:\n\t\tj += 1\n\t\tif j == n:\n\t\t\tt = n - 1\n\t\t\tbreak\n\telse:\n\t\tt = j - 1\n\tj = t\n\tsum += j - i\n\tif i < n - 2:\n\t\ti += 1\n\telse:\n\t\tbreak\n\tif j < n - 1:\n\t\tj += 1\nprint(sum)\n", "n = int(input())\ns = list(map(lambda x: abs(int(x)), input().split()))\ns.sort()\nr = 0\nfrom bisect import bisect\nfor i in s:\n\tr += bisect(s, 2 * i) - bisect(s, i - 1) - 1\nprint(r + len(set(s)) - len(s))\n", "import bisect\nimport math\nn = int(input())\nlg = [math.fabs(int(j)) for j in input().split()]\nlg.sort()\ns = 0\nfor i in range(n - 1, -1, -1):\n\ts += i - bisect.bisect_left(lg, math.ceil(lg[i] / 2))\nprint(s)\n", "from bisect import bisect_right, bisect_left\nn = int(input())\na = [abs(int(x)) for x in input().split(' ')]\na.sort()\nr = 0\nfor i in range(1, n):\n\te = a[i]\n\tx = e // 2\n\tif e % 2:\n\t\tx += 1\n\tj = bisect_left(a, x)\n\tr += i - j\nprint(r)\n", "RI = lambda : [int(x) for x in input().split()]\nfrom collections import defaultdict as df\nimport sys\nn = int(input())\nl = RI()\nfor i in range(len(l)):\n\tl[i] = abs(l[i])\nl.sort()\nans = 0\nfor i in range(len(l)):\n\tstart = i\n\tend = n - 1\n\twhile start <= end:\n\t\tmid = (start + end) // 2\n\t\tif l[mid] - l[i] > l[i]:\n\t\t\tend = mid - 1\n\t\telse:\n\t\t\tstart = mid + 1\n\tans += end - i\nprint(ans)\n", "n = int(input())\nL = sorted([abs(int(x)) for x in input().split()])\nT = 0\nfor i in range(n - 1):\n\t(l, h) = (i, n - 1)\n\twhile h != l:\n\t\tif L[(l + h + 1) // 2] <= 2 * L[i]:\n\t\t\tl = (l + h + 1) // 2\n\t\telse:\n\t\t\th = (l + h) // 2\n\tT += l - i\nprint(T)\n", "n = int(input())\na = list(map(abs, map(int, input().split())))\na.sort()\nfrom bisect import bisect_left\nans = 0\nfor (i, e) in enumerate(a):\n\tx = bisect_left(a, (e + 1) // 2)\n\tans += i - x\nprint(ans)\n", "def bin(x, st, en):\n\tif st <= en:\n\t\tmid = (st + en) // 2\n\t\tif l[mid] <= 2 * x:\n\t\t\tif mid + 1 < len(l):\n\t\t\t\tif l[mid + 1] > 2 * x:\n\t\t\t\t\treturn mid\n\t\t\telse:\n\t\t\t\treturn mid\n\t\t\treturn bin(x, mid + 1, en)\n\t\telif l[mid] > 2 * x:\n\t\t\treturn bin(x, st, mid - 1)\n\telse:\n\t\treturn -1\nn = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\ncount = 0\nfor i in range(n):\n\tz = bin(l[i], i + 1, n - 1)\n\tif z != -1:\n\t\tcount += z - i\nprint(count)\n", "n = int(input())\ns = input().split()\nv = [abs(int(x)) for x in s]\nans = 0\nv.sort()\nfor i in range(n):\n\tlo = i + 1\n\thi = n - 1\n\tpos = -1\n\twhile lo <= hi:\n\t\tmid = (lo + hi) // 2\n\t\tif v[mid] <= 2 * v[i]:\n\t\t\tpos = mid\n\t\t\tlo = mid + 1\n\t\telse:\n\t\t\thi = mid - 1\n\tif pos != -1:\n\t\tans += pos - i\nprint(ans)\n", "import os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\nfrom collections import defaultdict\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\nn = int(input())\na = list(map(int, input().split()))\na.sort()\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\nres = 0\nr = 1\nfor i in range(n - 1):\n\twhile r < n and a[r] <= 2 * a[i]:\n\t\tr += 1\n\tres += r - i - 1\nprint(res)\n", "import sys\nimport math\nfrom bisect import bisect_right as br\n\ndef int_arr():\n\treturn list(map(int, sys.stdin.readline().split()))\n\ndef str_arr():\n\treturn list(map(str, sys.stdin.readline().split()))\n\ndef input():\n\treturn sys.stdin.readline().strip()\nn = int(input())\narr = int_arr()\nfor i in range(n):\n\tif arr[i] < 0:\n\t\tarr[i] = arr[i] * -1\narr.sort()\nans = 0\nfor i in range(n):\n\tx = arr[i] * 2\n\tind = br(arr, x, i + 1)\n\tans += ind - 1 - i\nprint(ans)\n", "import bisect\nn = int(input())\narr = sorted(list(map(lambda x: abs(int(x)), input().split())))\npairs = 0\nfor i in range(n):\n\tpairs += bisect.bisect_right(arr, 2 * arr[i]) - i - 1\nprint(pairs)\n", "def main():\n\tn = int(input())\n\tarr = [abs(int(a)) for a in input().split()]\n\tarr.sort()\n\tfrom bisect import bisect\n\tans = 0\n\tfor i in range(n):\n\t\tj = bisect(arr, 2 * arr[i])\n\t\tans += max(0, j - i - 1)\n\tprint(ans)\nmain()\n", "from bisect import bisect_left\nn = int(input())\narr = list(map(int, input().split()))\nfor i in range(n):\n\tarr[i] = abs(arr[i])\narr.sort()\nans = 0\nfor i in range(n):\n\telem = arr[i]\n\tnext_elem = 2 * elem + 1\n\tind = bisect_left(arr, next_elem, 0, n)\n\tans += ind - i - 1\nprint(ans)\n", "from sys import stdin, stdout\nfrom bisect import bisect_left, bisect_right\n\ndef BinarySearch(a, x):\n\ti = bisect_right(a, x)\n\tif i:\n\t\treturn i - 1\n\telse:\n\t\treturn -1\n\ndef findlefftright(a, x):\n\tt1 = BinarySearch(a, x)\n\tele_left = t1 + 1\n\tele_right = len(a) - ele_left\n\treturn (ele_left, ele_right)\nn = int(stdin.readline().strip())\narr = list(map(int, stdin.readline().strip().split(' ')))\narr.sort()\np1 = []\nn1 = []\nfor i in range(len(arr)):\n\tif arr[i] >= 0:\n\t\tp1 = arr[i:]\n\t\tn1 = arr[:i]\n\t\tbreak\nif len(n1) == 0 and len(p1) == 0:\n\tn1 = arr\nn1 = list(map(abs, n1))\nn1.sort()\nans = 0\nfor i in range(len(n1)):\n\tt1 = ans\n\tans += findlefftright(n1, 2 * abs(n1[i]))[0] - findlefftright(n1, n1[i])[0]\nif len(p1) > 1:\n\tfor i in range(len(p1)):\n\t\tt1 = ans\n\t\tans += findlefftright(p1, 2 * p1[i])[0] - findlefftright(p1, p1[i])[0]\nfor i in range(len(n1)):\n\tt1 = ans\n\tif n1[i] % 2 == 0:\n\t\tans += findlefftright(p1, 2 * abs(n1[i]))[0] - findlefftright(p1, abs(n1[i]) // 2 - 1)[0]\n\telse:\n\t\tans += findlefftright(p1, 2 * abs(n1[i]))[0] - findlefftright(p1, abs(n1[i]) // 2)[0]\nstdout.write(str(ans))\n", "N = int(input())\nA = list(map(int, input().split()))\n\ndef count(X, Y):\n\tres = 0\n\tr = 0\n\tr2 = 0\n\tY = [-10 ** 10] + Y + [10 ** 10]\n\tfor l in range(len(X)):\n\t\txl = X[l]\n\t\tfor _ in range(len(Y)):\n\t\t\tif Y[r + 1] <= 2 * xl:\n\t\t\t\tr += 1\n\t\t\t\tcontinue\n\t\t\tbreak\n\t\tfor _ in range(len(Y)):\n\t\t\tif Y[r2 + 1] < xl:\n\t\t\t\tr2 += 1\n\t\t\t\tcontinue\n\t\t\tbreak\n\t\tres += max(0, r - r2)\n\treturn res\nAP = [a for a in A if a > 0]\nAP.sort()\nAN = [-a for a in A if a < 0]\nAN.sort()\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\n", "from bisect import bisect_left\nn = int(input())\na = list(map(int, input().split()))\na = list(sorted([max(i, -i) for i in a]))\nans = 0\nfor i in range(len(a)):\n\tleft = bisect_left(a, a[i] / 2)\n\tans += i - left\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\na = sorted([abs(x) for x in a])\ntotal = 0\ni = 0\nfor (j, h) in enumerate(a[:-1]):\n\th *= 2\n\twhile i < n - 1 and a[i + 1] <= h:\n\t\ti += 1\n\ttotal += i - j\nprint(total)\n", "from sys import stdin, stdout\n\ndef input():\n\treturn stdin.readline()[:-1]\nimport math\n\ndef abs_int(a):\n\treturn abs(int(a))\nn = int(input())\na = list(map(abs_int, input().split()))\na.sort()\nptr = 0\nhalf = -1\ngt_than_half = [0] * n\nfor i in range(n):\n\thalf = math.ceil(a[i] / 2)\n\twhile a[ptr] < half:\n\t\tptr += 1\n\tgt_than_half[i] = i - ptr\na.reverse()\nptr = 0\ntwice = -1\nlt_than_twice = [0] * n\nfor i in range(n):\n\ttwice = 2 * a[i]\n\twhile a[ptr] > twice:\n\t\tptr += 1\n\tlt_than_twice[i] = i - ptr\nprint((sum(gt_than_half) + sum(lt_than_twice)) // 2)\n", "n = int(input())\na = [int(i) for i in input().split()]\nrng = {}\ni = 0\nj = i + 1\na.sort(key=lambda x: abs(x))\nans = 0\n\ndef satisfy(x, y):\n\told_x = abs(x)\n\told_y = abs(y)\n\tmn = min(old_y, old_x)\n\tmx = max(old_x, old_x)\n\tnew = [abs(y - x), abs(y + x)]\n\tif any((i <= mn for i in new)) and any((i >= mx for i in new)):\n\t\treturn True\n\treturn False\nwhile j < len(a):\n\twhile not satisfy(a[i], a[j]) and i < j:\n\t\ti += 1\n\tans += j - i\n\tj += 1\nprint(ans)\n", "n = int(input())\nc = [abs(int(c)) for c in input().split()]\nc = sorted(c)\n\ndef binsearch(nums, target, xy):\n\tleft = xy\n\tright = len(nums) - 1\n\twhile left <= right:\n\t\tmid = (left + right) // 2\n\t\tif nums[mid] == target:\n\t\t\treturn mid\n\t\telif nums[mid] > target:\n\t\t\tright = mid - 1\n\t\telif nums[mid] < target:\n\t\t\tleft = mid + 1\n\treturn left - 1\nres = 0\nans = 0\nfor x in range(n):\n\tres += binsearch(c, 2 * c[x], x) - x\npt1 = 0\nif n == 2:\n\tif c[1] <= c[0] * 2:\n\t\tprint(1)\n\telse:\n\t\tprint(0)\n\texit()\nfor i in range(n):\n\twhile pt1 < n and c[pt1] <= 2 * c[i]:\n\t\tpt1 += 1\n\tif pt1 >= n or c[pt1] > 2 * c[i]:\n\t\tpt1 -= 1\n\tans += pt1 - i\nprint(ans)\n", "from bisect import bisect_right\nn = int(input())\na = sorted([int(x) if int(x) >= 0 else -1 * int(x) for x in input().split()])\nans = 0\nfor i in range(n):\n\tp = bisect_right(a, 2 * a[i])\n\tans += p - i - 1\nprint(ans)\n", "from bisect import bisect_left as lb, bisect_right as ub\n\ndef legend(x, y):\n\t(a1, a2) = sorted([abs(x), abs(y)])\n\t(v1, v2) = sorted([abs(x - y), abs(x + y)])\n\treturn True if v1 <= a1 and a2 <= v2 else False\ninput()\na = list(map(int, input().split()))\nif 0 in a:\n\ta.remove(0)\na.sort()\nt = 0\nfor x in a:\n\tt1 = 0\n\tif x < 0:\n\t\tb = ub(a, -x / 2)\n\t\tt += ub(a, x / 2) - ub(a, x)\n\t\tt += ub(a, -2 * x) - b\n\t\tif a[b - 1] == -x / 2:\n\t\t\tt += 1\n\telse:\n\t\tt += ub(a, 2 * x) - ub(a, x)\nprint(t)\n", "class Tale:\n\tn = int(input())\n\ta = list(map(lambda x: abs(int(x)), input().split()))\n\ta.sort()\n\tcounter = 0\n\tj = 0\n\tfor i in range(n):\n\t\twhile a[j] * 2 < a[i]:\n\t\t\tj += 1\n\t\tcounter += i - j\n\tprint(counter)\n", "n = int(input())\na = list(map(int, input().split()))\na = [abs(x) for x in a]\na.sort()\ncount = 0\nfor i in range(n - 1):\n\tnum = abs(a[i])\n\tl = +1\n\tr = n - 1\n\twhile l < r:\n\t\tidex = (l + r + 1) // 2\n\t\tif abs(a[idex]) - abs(num) <= num:\n\t\t\tl = idex\n\t\telse:\n\t\t\tr = idex - 1\n\tif abs(num - abs(a[l])) <= num:\n\t\tcount += l - i\nprint(count)\n", "n = int(input())\na = sorted([abs(int(i)) for i in input().split()])\ncount = 0\nj = 0\nfor i in range(n):\n\tlim = 2 * a[i]\n\twhile j < n and a[j] <= lim:\n\t\tj += 1\n\tcount += j - i - 1\nprint(count)\n", "n = int(input())\na = [abs(int(i)) for i in input().split()]\na.sort()\ncount = 0\ni = 0\nj = 1\nans = 0\nwhile i < n - 1:\n\twhile j < n and a[j] <= 2 * a[i]:\n\t\tj = j + 1\n\tans = ans + j - i - 1\n\ti = i + 1\nprint(ans)\n", "from bisect import bisect_right\nn = int(input())\na = list(map(int, input().split()))\na = [abs(a[i]) for i in range(n)]\na.sort()\nans = 0\nfor i in range(n):\n\tt = bisect_right(a, a[i] // 2)\n\tif a[t - 1] == a[i] // 2 and a[i] % 2 == 0:\n\t\tt -= 1\n\twhile t > 0 and a[t] == a[t - 1]:\n\t\tt -= 1\n\tans += i - t\nprint(ans)\n", "import sys\ntry:\n\tsys.stdin = open('input.txt', 'r')\n\tprint('READ FROM FILE')\nexcept:\n\tpass\nn = int(input().rstrip())\na = sorted(map(abs, map(int, input().rstrip().split())))\nans = 0\nl = 0\nfor r in range(1, n):\n\twhile l < r and 2 * a[l] < a[r]:\n\t\tl += 1\n\tans += r - l\nprint(ans)\n", "import sys\nDEBUG = False\nif DEBUG:\n\tinf = open('input.txt')\nelse:\n\tinf = sys.stdin\nN = int(inf.readline())\nnums = sorted(map(abs, map(int, inf.readline().split())))\n\ndef finder(x, st):\n\tlow = st\n\thigh = N - 1\n\tsol = 0\n\twhile low <= high:\n\t\tmid = (high + low) // 2\n\t\tif nums[mid] <= x:\n\t\t\tlow = mid + 1\n\t\t\tsol = mid\n\t\telse:\n\t\t\thigh = mid - 1\n\t\t\tsol = mid - 1\n\treturn sol\ntot = 0\nii = 1\nfor (i, num) in enumerate(nums):\n\twhile ii < N and nums[ii] <= num * 2:\n\t\tii += 1\n\tn = ii - i - 1\n\ttot += n\nprint(tot)\n", "n = int(input())\nl = list(map(int, input().split()))\na = [abs(l[i]) for i in range(n)]\na.sort()\nwyn = 0\nwsk1 = 0\nwsk2 = 1\nlicz = 0\nwhile True:\n\tif a[wsk1] * 2 < a[wsk2]:\n\t\twyn += wsk2 - wsk1 - 1\n\t\twsk1 += 1\n\telse:\n\t\twsk2 += 1\n\tif wsk2 == n:\n\t\tbreak\nwyn += (n - wsk1) * (n - wsk1 - 1) // 2\nprint(wyn)\n", "n = int(input())\na = list(map(int, input().split()))\nc = 0\na = [abs(i) for i in a]\na.sort()\nj = 0\nfor i in range(n - 1):\n\twhile j < n - 1 and a[j + 1] <= 2 * a[i]:\n\t\tj += 1\n\tc += j - i\nprint(c)\n", "import sys\nfrom bisect import bisect_left, bisect_right, insort\nfrom collections import deque, Counter\nfrom math import gcd, sqrt, factorial, ceil, log10, log2, floor\nfrom itertools import permutations\nfrom heapq import heappush, heappop, heapify\ninf = float('inf')\nmod = 998244353\n\ndef factorial_p(n, p):\n\tans = 1\n\tif n <= p // 2:\n\t\tfor i in range(1, n + 1):\n\t\t\tans = ans * i % p\n\telse:\n\t\tfor i in range(1, p - n):\n\t\t\tans = ans * i % p\n\t\tans = pow(ans, p - 2, p)\n\t\tif n % 2 == 0:\n\t\t\tans = p - ans\n\treturn ans\n\ndef nCr_p(n, r, p):\n\tans = 1\n\twhile n != 0 or r != 0:\n\t\t(a, b) = (n % p, r % p)\n\t\tif a < b:\n\t\t\treturn 0\n\t\tans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p\n\t\tn //= p\n\t\tr //= p\n\treturn ans\n\ndef prime_sieve(n):\n\tflag = n % 6 == 2\n\tsieve = bytearray((n // 3 + flag >> 3) + 1)\n\tfor i in range(1, int(n ** 0.5) // 3 + 1):\n\t\tif not sieve[i >> 3] >> (i & 7) & 1:\n\t\t\tk = 3 * i + 1 | 1\n\t\t\tfor j in range(k * k // 3, n // 3 + flag, 2 * k):\n\t\t\t\tsieve[j >> 3] |= 1 << (j & 7)\n\t\t\tfor j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):\n\t\t\t\tsieve[j >> 3] |= 1 << (j & 7)\n\treturn sieve\n\ndef prime_list(n):\n\tres = []\n\tif n > 1:\n\t\tres.append(2)\n\tif n > 2:\n\t\tres.append(3)\n\tif n > 4:\n\t\tsieve = prime_sieve(n + 1)\n\t\tres.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))\n\treturn res\n\ndef is_prime(n):\n\tif n < 5 or n & 1 == 0 or n % 3 == 0:\n\t\treturn 2 <= n <= 3\n\ts = (n - 1 & 1 - n).bit_length() - 1\n\td = n >> s\n\tfor a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:\n\t\tp = pow(a, d, n)\n\t\tif p == 1 or p == n - 1 or a % n == 0:\n\t\t\tcontinue\n\t\tfor _ in range(s):\n\t\t\tp = p * p % n\n\t\t\tif p == n - 1:\n\t\t\t\tbreak\n\t\telse:\n\t\t\treturn False\n\treturn True\n\ndef all_factors(n):\n\t(small, large) = ([], [])\n\tfor i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):\n\t\tif not n % i:\n\t\t\tsmall.append(i)\n\t\t\tlarge.append(n // i)\n\tlarge.reverse()\n\tsmall.extend(large)\n\treturn small\n\ndef count(n):\n\treturn n * (n + 1) // 2\n\ndef get_array():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n\ndef get_ints():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef input():\n\treturn sys.stdin.readline().strip()\nn = int(input())\nA = [abs(int(x)) for x in input().split()]\nA.sort()\nans = 0\nj = 0\nfor i in range(n):\n\tx = A[i]\n\twhile j < n:\n\t\ty = A[j]\n\t\tif abs(x - y) <= abs(x) <= abs(x + y) and abs(x - y) <= abs(y) <= abs(x + y):\n\t\t\tj += 1\n\t\telse:\n\t\t\tbreak\n\tans += j - i - 1\nprint(ans)\n", "import sys\nread = sys.stdin.readline\n\ndef b_search(l, r, n):\n\tif l == r:\n\t\tif A[l] >= n:\n\t\t\treturn l\n\t\telse:\n\t\t\treturn l + 1\n\tmid = (l + r) // 2\n\tif A[mid] > n:\n\t\treturn b_search(l, mid, n)\n\telif A[mid] < n:\n\t\treturn b_search(mid + 1, r, n)\n\treturn mid\nN = int(input())\nA = list(map(int, read().split()))\nfor i in range(N):\n\tif A[i] < 0:\n\t\tA[i] = -A[i]\nA.sort()\ng_count = 0\nfor right in reversed(range(1, N)):\n\thalf = A[right] // 2 if A[right] % 2 == 0 else (A[right] + 1) // 2\n\tidx = b_search(0, right - 1, half)\n\tif idx != right:\n\t\twhile A[idx] < half:\n\t\t\tidx += 1\n\tif idx != 0:\n\t\tif A[idx] == A[idx - 1]:\n\t\t\tidx -= 1\n\tcnt = right - idx\n\tg_count += cnt\nprint(g_count)\n", "from bisect import *\nn = int(input())\na = sorted([abs(int(i)) for i in input().split()])\nans = 0\nfor (idx, ele) in enumerate(a):\n\tans += max(bisect_right(a, ele * 2) - idx - 1, 0)\nprint(ans)\n", "import sys\nimport bisect\nimport math\n\ndef input():\n\treturn sys.stdin.readline().strip()\nn = int(input())\nq = list(map(int, input().split()))\nfor i in range(len(q)):\n\tq[i] = abs(q[i])\nq.sort()\ns = 0\nfor i in range(n):\n\tc1 = bisect.bisect_left(q, math.ceil(q[i] / 2)) - 1\n\tc2 = bisect.bisect_right(q, q[i] * 2) - 1\n\tif c1 == -1 or q[c1] * 2 < q[i]:\n\t\tc1 += 1\n\tif q[c2] > q[i] * 2 or c2 == n:\n\t\tc2 -= 1\n\tif i > c1 and q[i] <= q[c1] * 2:\n\t\ts += i - c1\n\tif i < c2 and q[i] * 2 >= q[c2]:\n\t\ts += c2 - i\nprint(s // 2)\n", "import bisect\n\ndef main():\n\tn = int(input())\n\ta = [abs(int(x)) for x in input().split()]\n\ta.sort()\n\tans = 0\n\tfor i in range(n):\n\t\tans += bisect.bisect_right(a, 2 * a[i]) - bisect.bisect_right(a, a[i])\n\t\tif a[i] == a[i - 1]:\n\t\t\tans += 1\n\tprint(ans)\nmain()\n", "import bisect\nn = int(input())\na = list(map(int, input().split()))\na = sorted(a)\nans = 0\nfor i in range(len(a)):\n\tif a[i] < 0:\n\t\tr = bisect.bisect_left(a, a[i] // 2 + 1)\n\t\tl = bisect.bisect_left(a, a[i] + 1)\n\t\tans += r - l\n\t\tr = bisect.bisect_left(a, -a[i] * 2 + 1)\n\t\tl = bisect.bisect_left(a, -(a[i] // 2))\n\t\tans += r - l\n\telif a[i] > 0:\n\t\tr = bisect.bisect_left(a, 2 * a[i] + 1)\n\t\tl = bisect.bisect_left(a, a[i] + 1)\n\t\tans += r - l\nprint(ans)\n", "import os, io\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\nn = int(input())\na = list(map(int, input().split()))\na = sorted(list(map(abs, a)))\nout = 0\ni = 0\nj = 1\nwhile i < n:\n\tnum = a[i]\n\tif j < n and a[j] <= 2 * num:\n\t\tj += 1\n\telse:\n\t\tout += max(0, j - 1 - i)\n\t\ti += 1\nprint(out)\n", "def check_borders(n, borders):\n\tborders = sorted(borders, reverse=True, key=abs)\n\tnum_of_pairs = 0\n\tcurrent_x = 0\n\tcurrent_y = 1\n\twhile current_x != n - 1:\n\t\tdiff = abs(borders[min(current_y, n - 1)]) >= abs(borders[current_x]) / 2\n\t\tif diff:\n\t\t\twhile current_y < n and abs(borders[current_y]) >= abs(borders[current_x]) / 2:\n\t\t\t\tcurrent_y += 1\n\t\t\tnum_of_pairs += current_y - current_x - 1\n\t\telse:\n\t\t\twhile not abs(borders[current_y]) >= abs(borders[current_x]) / 2:\n\t\t\t\tcurrent_y -= 1\n\t\t\tnum_of_pairs += current_y - current_x\n\t\tcurrent_x += 1\n\treturn num_of_pairs\nn = int(input())\nborders = list(map(int, input().split()))\nprint(check_borders(n, borders))\n", "n = int(input())\na = map(int, input().split())\na = list((abs(i) for i in set(a)))\na.sort()\ni = 0\nj = 0\nans = 0\nwhile i < len(a) - 1:\n\twhile j < len(a) and a[j] <= 2 * a[i]:\n\t\tj += 1\n\tans += j - i - 1\n\ti += 1\nprint(ans)\n", "import sys, math, queue\nMOD = 10 ** 9 + 7\n\ndef binleft(l, r, x):\n\tlow = l\n\thigh = r\n\tans = None\n\twhile low <= high:\n\t\tmid = (low + high) // 2\n\t\tif 2 * a[mid] < a[x]:\n\t\t\tans = mid\n\t\t\thigh = mid - 1\n\t\telse:\n\t\t\tlow = mid + 1\n\tif 2 * a[0] >= a[x]:\n\t\tans = -1\n\tif ans is None:\n\t\treturn 0\n\treturn r - ans\n\ndef binright(l, r, x):\n\tlow = l\n\thigh = r\n\tans = None\n\twhile low <= high:\n\t\tmid = (low + high) // 2\n\t\tif a[mid] <= 2 * a[x]:\n\t\t\tans = mid\n\t\t\tlow = mid + 1\n\t\telse:\n\t\t\thigh = mid - 1\n\tif ans is None:\n\t\treturn 0\n\treturn ans - x\nn = int(input())\na = sorted(map(lambda x: abs(int(x)), input().split()))\nn = len(a)\nlr = [0 for i in range(n)]\nrr = [0 for i in range(n)]\nans = 0\nfor i in range(n):\n\tans += binright(i + 1, n - 1, i)\nprint(ans)\n", "import bisect\nn = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\ni = 0\nans = 0\nwhile i < n:\n\tx = l[i]\n\th = x / 2\n\tk = bisect.bisect_left(l, h) + 1\n\tans += i - k + 1\n\ti += 1\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\na.append(1000000000000000)\nlow = 0\nhigh = 0\ntot = 0\nwhile low < n:\n\tif a[high] <= 2 * a[low]:\n\t\thigh += 1\n\telse:\n\t\ttot += high - low - 1\n\t\tlow += 1\nprint(tot)\n", "from math import *\nfrom collections import *\nn = int(input())\nl = list(map(int, input().split()))\nfor i in range(n):\n\tl[i] = abs(l[i])\nl.sort()\nj = n - 2\nans = [0 for i in range(n)]\nfor i in range(n - 1, -1, -1):\n\twhile j > -1 and l[j] >= l[i] / 2:\n\t\tj -= 1\n\tans[i] = i - j - 1\nprint(sum(ans))\n", "import math\nfrom decimal import Decimal\n\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn (n, b)\n\ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn (n, b, c)\n\ndef dv():\n\t(n, m) = map(int, input().split())\n\treturn (n, m)\n\ndef dva():\n\t(n, m) = map(int, input().split())\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn (n, m, b)\n\ndef eratosthenes(n):\n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n\ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn (n, b, m, c)\n\ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn (n, m)\n(n, a) = na()\nfor i in range(n):\n\ta[i] = abs(a[i])\na.sort()\nj = 1\nj1 = 1\ndop = 0\nans = 0\nfor i in range(0, n - 1):\n\twhile j < n:\n\t\tif a[j] <= 2 * a[i]:\n\t\t\tdop += 1\n\t\t\tj += 1\n\t\telse:\n\t\t\tbreak\n\tans = ans + dop + j1 - i - 1\n\tdop = 0\n\tj1 = j\nprint(ans)\n", "mod = 1000000007\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nfrom bisect import *\nn = ii()\nl = sorted(list(map(lambda x: abs(int(x)), input().split())))\nc = 0\nfor i in range(n):\n\tc += bisect_right(l, 2 * l[i]) - i - 1\nprint(c)\n", "import bisect\nimport decimal\nfrom decimal import Decimal\nimport os\nfrom collections import Counter\nimport bisect\nfrom collections import defaultdict\nimport math\nimport random\nimport heapq\nfrom math import sqrt\nimport sys\nfrom functools import reduce, cmp_to_key\nfrom collections import deque\nimport threading\nfrom itertools import combinations\nfrom io import BytesIO, IOBase\nfrom itertools import accumulate\ndecimal.getcontext().prec = 46\n\ndef primeFactors(n):\n\tprime = set()\n\twhile n % 2 == 0:\n\t\tprime.add(2)\n\t\tn = n // 2\n\tfor i in range(3, int(math.sqrt(n)) + 1, 2):\n\t\twhile n % i == 0:\n\t\t\tprime.add(i)\n\t\t\tn = n // i\n\tif n > 2:\n\t\tprime.add(n)\n\treturn list(prime)\n\ndef getFactors(n):\n\tfactors = []\n\ti = 1\n\twhile i <= math.sqrt(n):\n\t\tif n % i == 0:\n\t\t\tif n // i == i:\n\t\t\t\tfactors.append(i)\n\t\t\telse:\n\t\t\t\tfactors.append(i)\n\t\t\t\tfactors.append(n // i)\n\t\ti = i + 1\n\treturn factors\n\ndef SieveOfEratosthenes(n):\n\tprime = [True for i in range(n + 1)]\n\tp = 2\n\twhile p * p <= n:\n\t\tif prime[p] == True:\n\t\t\tfor i in range(p * p, n + 1, p):\n\t\t\t\tprime[i] = False\n\t\tp += 1\n\tnum = []\n\tfor p in range(2, n + 1):\n\t\tif prime[p]:\n\t\t\tnum.append(p)\n\treturn num\n\ndef lcm(a, b):\n\treturn a * b // math.gcd(a, b)\n\ndef sort_dict(key_value):\n\treturn sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))\n\ndef list_input():\n\treturn list(map(int, input().split()))\n\ndef num_input():\n\treturn map(int, input().split())\n\ndef string_list():\n\treturn list(input())\n\ndef decimalToBinary(n):\n\treturn bin(n).replace('0b', '')\n\ndef binaryToDecimal(n):\n\treturn int(n, 2)\n\ndef DFS(n, s, adj):\n\tvisited = [False for i in range(n + 1)]\n\tstack = []\n\tstack.append(s)\n\twhile len(stack):\n\t\ts = stack[-1]\n\t\tstack.pop()\n\t\tif not visited[s]:\n\t\t\tvisited[s] = True\n\t\tfor node in adj[s]:\n\t\t\tif not visited[node]:\n\t\t\t\tstack.append(node)\n\ndef solve():\n\tn = int(input())\n\tarr = []\n\tfor i in list_input():\n\t\tarr.append(abs(i))\n\tarr.sort()\n\tbrr = []\n\tfor i in arr:\n\t\tbrr.append(math.ceil(i / 2))\n\tpairs = 0\n\ti = n - 1\n\twhile i >= 0:\n\t\tarr.pop()\n\t\tindx = bisect.bisect_left(arr, brr[i])\n\t\tpairs += len(arr) - indx\n\t\ti -= 1\n\tprint(pairs)\nt = 1\nfor _ in range(t):\n\tsolve()\n", "from bisect import bisect, bisect_left\nn = int(input())\nys = set(map(int, input().split())) - {0}\nxs = sorted(ys)\nans = 0\nfor x in xs:\n\tif x > 0:\n\t\tbreak\n\tans -= -x in ys\nfor x in xs:\n\ta = abs(x)\n\taa = a * 2\n\tans += bisect(xs, aa) - bisect_left(xs, a) + bisect(xs, -a) - bisect_left(xs, -aa) - 1\nprint(ans)\n", "n = int(input())\na = []\nd = list(map(int, input().split()))\nfor i in range(len(d)):\n\ta.append(abs(d[i]))\na.sort()\nj = 0\nc = 0\nfor i in range(n - 1):\n\twhile j + 1 < n and a[j + 1] - a[i] <= a[i]:\n\t\tj = j + 1\n\tc = c + j - i\nprint(c)\n", "import bisect\nn = int(input())\nx = [abs(int(g)) for g in input().split()]\ncount = 0\nx.sort()\nfor i in range(n):\n\tdouble = 2 * x[i]\n\tl = bisect.bisect(x, double)\n\tindex = l - i - 1\n\tcount += index\nprint(count)\n", "from sys import stdin, stdout\nimport bisect\nfrom itertools import combinations\nfrom collections import defaultdict, OrderedDict, Counter\nimport math\n\ndef listIn():\n\treturn list(map(int, stdin.readline().strip().split()))\n\ndef stringListIn():\n\treturn [x for x in stdin.readline().split()]\n\ndef intIn():\n\treturn int(stdin.readline())\n\ndef stringIn():\n\treturn stdin.readline().strip()\nn = intIn()\na = listIn()\na = [abs(x) for x in a]\na.sort()\ncount = Counter(a)\nb = sorted(set(a))\nl = len(b)\narr = [0] * n\nfor i in range(n):\n\tidx = bisect.bisect_right(a, 2 * a[i]) - 1\n\tarr[i] = idx - i\nprint(sum(arr))\n", "import math\nn = int(input())\nlis = list(map(int, input().split()))\nfor i in range(len(lis)):\n\tlis[i] = abs(lis[i])\nlis.sort()\nans = 0\ni = 0\nj = 1\nwhile j < n:\n\tif i < j:\n\t\tif lis[j] - lis[i] <= lis[i]:\n\t\t\tans += 1\n\t\t\tif j < n - 1:\n\t\t\t\tj += 1\n\t\t\telse:\n\t\t\t\ti += 1\n\t\t\t\tif i != j:\n\t\t\t\t\tans += j - i - 1\n\t\telse:\n\t\t\ti += 1\n\t\t\tif i != j:\n\t\t\t\tans += j - i - 1\n\telif j == i and j < n - 1:\n\t\tj += 1\n\telse:\n\t\tbreak\nprint(ans)\n", "import itertools\nimport collections\nimport heapq\nimport bisect\nimport math\nimport sys\nimport operator\nimport string\nnc = int(input())\noptions = map(int, input().split())\nabsopts = list(map(abs, options))\nabsopts.sort()\ntpos = 0\nres = 0\nfor i in range(nc):\n\twhile tpos < nc and absopts[tpos] <= absopts[i] * 2:\n\t\ttpos += 1\n\tres += max(0, tpos - i - 1)\nprint(res)\n", "def calcindex(start, end, arr, num):\n\tif start == end:\n\t\tif arr[start] <= num:\n\t\t\treturn end\n\t\telse:\n\t\t\treturn end - 1\n\telse:\n\t\tmid = (start + end) // 2\n\t\tif arr[mid] > num and arr[mid - 1] <= num:\n\t\t\treturn mid - 1\n\t\telif arr[mid] > num:\n\t\t\tend = mid - 1\n\t\t\treturn calcindex(start, end, arr, num)\n\t\telse:\n\t\t\tstart = mid + 1\n\t\t\treturn calcindex(start, end, arr, num)\nn = int(input())\nl = list(map(int, input().split()))\nnew = []\nfor i in l:\n\tif i > 0:\n\t\tnew.append(i)\n\telse:\n\t\tnew.append(i * -1)\nnew.sort()\ncount = 0\nfor i in range(n - 1):\n\ttemp = calcindex(i + 1, n - 1, new, 2 * new[i])\n\tcount += temp - i\nprint(count)\n"]

difficulty: MEDIUM

source: codeforces

raw_problem:
C. A Tale of Two Lands

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

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$$$:

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]$$$:

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:

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

question:
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](1.png) 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](2.png) 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](3.png) Note that even though Arrayland and Vectorland share $$$3$$$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.

skill_types: ['Sorting', 'Amortized analysis']

raw_tags: ['two pointers', 'binary search', 'sortings']

image_tags:
Linear Data Structure
Linear Data Structure
Linear Data Structure

data_split: test


Tree Construction

source: ACM-ICPC Japan Alumni Group Winter Contest 2009

raw_problem:
Problem J: Tree Construction

Consider a two-dimensional space with a set of points (<var>xi</var>,
<var>yi</var>) that satisfy <var>xi</var> < <var>xj</var>
and <var>yi</var> > <var>yj</var> for all <var>i < j</var>.
We want to have them all connected by a directed tree whose edges go toward
either right (<var>x</var> positive) or upward (<var>y</var> positive). The
figure below shows an example tree.

Figure 1: An example tree

Write a program that finds a tree connecting all given points with the
shortest total length of edges.

Input

The input begins with a line that contains an integer <var>n</var> (1 <=
<var>n</var> <= 1000), the number of points. Then <var>n</var> lines follow. The
<var>i</var>-th line contains two integers <var>xi</var> and <var>yi</var>
(0 <= <var>xi</var>, <var>yi</var> <= 10000), which give
the coordinates of the <var>i</var>-th point.

Output

Print the total length of edges in a line.

Sample Input 1

5
1 5
2 4
3 3
4 2
5 1

Output for the Sample Input 1

12

Sample Input 2

1
10000 0

Output for the Sample Input 2

0

source: aizu

question:
Problem J: Tree Construction
Consider a two-dimensional space with a set of points ($x_{i}$,
$y_{i}$) that satisfy $x_{i}$ < $x_{j}$
and $y_{i}$ > $y_{j}$ for all $i < j$.
We want to have them all connected by a directed tree whose edges go toward
either right ($x$ positive) or upward ($y$ positive). The
figure below shows an example tree.
![image](1.png)
Figure 1: An example tree
Write a program that finds a tree connecting all given points with the
shortest total length of edges.
Input
The input begins with a line that contains an integer $n$ (1 <=
$n$ <= 1000), the number of points. Then $n$ lines follow. The
$i$-th line contains two integers $x_{i}$ and $y_{i}$
(0 <= $x_{i}$, $y_{i}$ <= 10000), which give
the coordinates of the $i$-th point.
Output
Print the total length of edges in a line.
Sample Input 1

5
1 5
2 4
3 3
4 2
5 1

Output for the Sample Input 1
12
Sample Input 2

1
10000 0

Output for the Sample Input 2
0

data_split: test