Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> int:
    modulo = 10**9+7
    N = read_int()
    A = read_ints()
    lcd = 1
    for a in A:
        lcd = a*lcd//math.gcd(a, lcd)
    return sum((lcd//a)%modulo for a in A)%modulo


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations, zip_longest, groupby


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))

modulo = 10**9+7


def merge(A, start, end, divisors):
    if start == end:
        return Counter(divisors[A[start]])
    mid = start+(end-start)//2
    left = merge(A, start, mid, divisors)
    right = merge(A, mid+1, end, divisors)
    for r in right:
        left[r] = max(left[r], right[r])
    return left

def solve() -> int:
    N = read_int()
    A = read_ints()
    M = 10**6+1
    divisors: List[List[int]] = [[] for _ in range(M)]
    for i in range(2, M):
        if len(divisors[i]) == 0:
            for j in range(i, M, i):
                temp = j
                while temp%i == 0:
                    divisors[j].append(i)
                    temp //= i
    lcd_counter = merge(A, 0, N-1, divisors)
    lcd = 1
    for k in lcd_counter:
        lcd = (lcd*pow(k, lcd_counter[k], modulo))%modulo
    answer = 0
    for a in A:
        answer = (answer+(lcd*pow(a, modulo-2, modulo))%modulo)%modulo
    return answer


if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        ans = a[0]
        for j in range(n):
            for k in range(n):
                ans = max(ans, sum(a[j:k + 1]))
        print(ans)

### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        for i in range(1, n):
            a[i] = max(a[i - 1] + a[i], a[i])
        print(max(a))
### BUGGY CODE ###

h,w=map(int, input().split())
ch,cw=map(int, input().split())
ch-=1
cw-=1
dh,dw=map(int, input().split())
dh-=1
dw-=1
grid=[]
for i in range(h):
    s=list(input())
    news=[-1 if x=='#' else 0 for x in s]
    grid.append(news)
dif=[(1,0),(-1,0),(0,1),(0,-1)]
from collections import deque
col=0
cand=set([])
for i in range(h):
    for j in range(w):
        if grid[i][j]!=0:
            continue
        else:
            col+=1
            stack=deque([(i,j)])
            while stack:
                nowi,nowj=stack.popleft()
                grid[nowi][nowj]=col
                for di,dj in dif:
                    if 0<=nowi+di<h and 0<=nowj+dj<w and grid[nowi+di][nowj+dj]==0:
                        stack.append((nowi+di,nowj+dj))
                    elif 0<=nowi+di<h and 0<=nowj+dj<w and grid[nowi+di][nowj+dj]==-1:
                        cand.add((nowi, nowj))

start=grid[ch][cw]-1
end=grid[dh][dw]-1

if start==end:
    print(0)
    exit()

es=[set([]) for _ in range(col)]
visited=[-1]*col
for i,j in cand:
    now=grid[i][j]
    if now!=-1: 
        for x in range(-2, 3):
            for y in range(-2, 3):
                if (x,y) in dif:
                    continue
                if 0<=i+x<h and 0<=j+y<w:
                    nex=grid[i+x][j+y]
                    if nex!=-1 and now!=nex:
                        es[now-1].add(nex-1)
stack=deque([start])
visited[start]=0
while stack:
    now=stack.popleft()
    v=visited[now]
    for e in es[now]:
        if visited[e]==-1:
            visited[e]=v+1
            stack.append(e)
#print(grid)
print(visited[end])

### FIXED CODE ###

h,w=map(int, input().split())
ch,cw=map(int, input().split())
ch-=1
cw-=1
dh,dw=map(int, input().split())
dh-=1
dw-=1
grid=[]
for i in range(h):
    s=list(input())
    news=[-1 if x=='#' else 0 for x in s]
    grid.append(news)
dif=[(1,0),(-1,0),(0,1),(0,-1)]
from collections import deque
col=0
for i in range(h):
    for j in range(w):
        if grid[i][j]==0:
            col+=1
            stack=deque([(i,j)])
            grid[i][j]=col
            while stack:
                nowi,nowj=stack.popleft()
                for di,dj in dif:
                    if 0<=nowi+di<h and 0<=nowj+dj<w and grid[nowi+di][nowj+dj]==0:
                        stack.append((nowi+di,nowj+dj))
                        grid[nowi+di][nowj+dj]=col
start=grid[ch][cw]-1
end=grid[dh][dw]-1
if start==end:
    print(0)
    exit()
es=[set([]) for _ in range(col)]
visited=[-1]*col

for i in range(h):
    for j in range(w):
        now=grid[i][j]
        if now!=-1: 
            for x in range(-2, 3):
                for y in range(-2, 3):
                    if 0<=i+x<h and 0<=j+y<w:
                        nex=grid[i+x][j+y]
                        if nex!=-1 and now!=nex:
                            es[now-1].add(nex-1)

stack=deque([start])
visited[start]=0
while stack:
    now=stack.popleft()
    for e in es[now]:
        if visited[e]==-1:
            visited[e]=visited[now]+1
            stack.append(e)
#print(grid)
print(visited[end])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
import itertools #list(accumulate(A))

S = input()
#S = 'abcdefghijklmnopqrstuvwxyz'*200
K = ii()
N = len(S)
'''
N = len(S)
d = defaultdict(int)
for i in range(N+1):
    for j in range(N-i+1):
        d[S[j:j+i+1]] += 1
l = sorted(d.keys())
#print(l)
print(l[K])
'''

alphabets = list('abcdefghijklmnopqrstuvwxyz')

#print(len(alphabets))
l = []
for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            for j in range(1, N-i+1):
                l.append(S[i:i+j])

    l = sorted(set(l))
    if len(l) >= K:
        print(l[K-1])
        exit()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
import itertools #list(accumulate(A))

S = input()
K = ii()
N = len(S)


alphabets = list('abcdefghijklmnopqrstuvwxyz')
l = []

for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            flag = 1
            for j in range(1, min(K+1, N-i+1)):
                l.append(S[i:i+j])
    #print(set(l))
    l = sorted(set(l))
    if len(l) >= K:
        print(l[K-1])
        exit()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=[A.index(i)+1 for i in range(1,N+1) ]
print(*ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
X=[0]*N
for i in range(N):
   X[A[i]-1]=i+1

print(*X)
### BUGGY CODE ###

int_n = int(input())
list_x = list(map(int, input().split()))

#print(max(list_x))

#同じ値には、最小のインデックスを返す
#print(list_x.index(max(list_x)))

int_plus = 0
list_x_left = list_x

while len(list_x_left) != 0:
  list_x_prosess = list_x_left[list_x_left.index(max(list_x_left)):]
  list_x_left = list_x_left[:list_x_left.index(max(list_x_left))]
  
  #  print(sum([max(list_x_prosess)-i for i in list_x_prosess]))
  int_plus = int_plus + sum([max(list_x_prosess)-i for i in list_x_prosess])

  #  print(list_x_left, list_x_prosess)
print(int_plus)

### FIXED CODE ###

int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)
### BUGGY CODE ###

class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect(self, i):
        l, r = 0, i
        s = self.sum(r)
        if s == 0:
            return 0
        while r - l > 1:
            m = (r + l) // 2
            if self.sum(m) < s:
                l = m
            else:
                r = m
        return l + 1


N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
B = [memo[a] for a in A]
M = len(memo) + 10

bit = BIT(M)
for b in B:
    i = bit.bisect(b - 1)
    if i != 0:
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


### FIXED CODE ###

from bisect import bisect_right

N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

L = [A[0]]
for a in A[1:]:
    if a >= L[-1]:
        L.append(a)
    else:
        L[bisect_right(L, a)] = a

print(len(L))
### BUGGY CODE ###

X, Y, Z, K = [int(_) for _ in input().split()]
As = [int(_) for _ in input().split()]
Bs = [int(_) for _ in input().split()]
Cs = [int(_) for _ in input().split()]

As.sort()
Bs.sort()
Cs.sort()

choice_stack = [(len(As) - 1, len(Bs) - 1, len(Cs) - 1)]
choice_stack_next = []
choice_log = set()
sums = []

j = 0
while True:
    for Ai, Bi, Ci in choice_stack:
        sums.append(As[Ai] + Bs[Bi] + Cs[Ci])
        cA = (max(0, Ai - 1), Bi, Ci)
        cB = (Ai, max(0, Bi - 1), Ci)
        cC = (Ai, Bi, max(0, Ci - 1))
        if not (cA in choice_log):
            choice_stack_next.append(cA)
            choice_log.add(cA)
        if not (cB in choice_log):
            choice_stack_next.append(cB)
            choice_log.add(cB)
        if not (cC in choice_log):
            choice_stack_next.append(cC)
            choice_log.add(cC)

    sums.sort()
    print(sums.pop())
    choice_stack = [_ for _ in choice_stack_next]
    choice_stack_next.clear()
    j += 1
    if j >= K:
        break


### FIXED CODE ###

X, Y, Z, K = [int(_) for _ in input().split()]
As = [int(_) for _ in input().split()]
Bs = [int(_) for _ in input().split()]
Cs = [int(_) for _ in input().split()]

As.sort()
Bs.sort()
Cs.sort()

choice_stack = [(As[-1] + Bs[-1] + Cs[-1], len(As) - 1, len(Bs) - 1, len(Cs) - 1)]
choice_log = set()

j = 0
while True:
    choice_stack.sort()
    chosen_sum, Ai, Bi, Ci = choice_stack.pop()

    print(chosen_sum)

    step_A = (As[max(0, Ai - 1)] + Bs[Bi] + Cs[Ci], max(0, Ai - 1), Bi, Ci)
    step_B = (As[Ai] + Bs[max(0, Bi - 1)] + Cs[Ci], Ai, max(0, Bi - 1), Ci)
    step_C = (As[Ai] + Bs[Bi] + Cs[max(0, Ci - 1)], Ai, Bi, max(0, Ci - 1))

    if not (step_A in choice_log):
        choice_stack.append(step_A)
        choice_log.add(step_A)
    if not (step_B in choice_log):
        choice_stack.append(step_B)
        choice_log.add(step_B)
    if not (step_C in choice_log):
        choice_stack.append(step_C)
        choice_log.add(step_C)

    j += 1
    if j >= K:
        break
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
N = len(A)
dictA = {i: A[i] for i in range(len(A))}
dictA_sorted = sorted(dictA.items(), key=lambda x:x[1])
A_sorted = [item[1] for item in dictA_sorted]
sorted_index = [item[0] for item in dictA_sorted]
for count in range(N):
    k = sorted_index.index(count)
    ways = 0
    i = 0
    if k == 0:
        B = A_sorted[1:]
    elif k == N - 1:
        B = A_sorted[:N - 1]
    else:
        B = A_sorted[:k] + A_sorted[k + 1:]
    while i < N - 1:
        head = B[i]
        j = 1
        while j + i < N - 1 and B[j + i] == head:
            j += 1
        ways +=  (j * (j - 1)) // 2
        i += j
    print(ways)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
C = [0 for i in range(N)]
for value in A:
    C[value - 1] += 1
ways_all = 0
for i in range(N):
    ways_all += (C[i] * (C[i] - 1)) // 2
for value in A:
    print(ways_all - C[value - 1] + 1)
### BUGGY CODE ###

import heapq

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

for i in range(M):
  B, C = map(int, input().split())
  for j in range(B):
    c = heapq.heappushpop(A, C)
    if c == C:
      break

print(sum(A))

### FIXED CODE ###

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

CB = []
for i in range(M):
  b, c = map(int, input().split())
  CB.append([c, b])

D = [[a, 1] for a in A] + CB

D.sort()

ans = 0
while N > 0:
  c, b = D.pop()
  ans += min(N, b)*c
  N -= b

print(ans)
### BUGGY CODE ###

# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
cd = [list(map(int, input().split())) for i in range(k)]

# 初期化
# 根なら-size,子なら親の頂点
par = [-1] * n

friend = [[0] * n for i in range(n)]
block = [[0] * n for i in range(n)]

not_see = [set() for i in range(n)]

for a, b in ab:
    a -= 1
    b -= 1
    unite(a, b)
    if same(a, b):
        not_see[a].add(b)
        not_see[b].add(a)

for c, d in cd:
    c -= 1
    d -= 1
    if same(c, d):
        not_see[c].add(d)
        not_see[d].add(c)

for i in range(n):
    print(size(i) - len(not_see[i]) - 1)

### FIXED CODE ###

from collections import defaultdict


# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
cd = [list(map(int, input().split())) for i in range(k)]

# 初期化
# 根なら-size,子なら親の頂点
par = [-1] * n

not_see = defaultdict(set)

for a, b in ab:
    a -= 1
    b -= 1
    unite(a, b)
    if same(a, b):
        not_see[a].add(b)
        not_see[b].add(a)

for c, d in cd:
    c -= 1
    d -= 1
    if same(c, d):
        not_see[c].add(d)
        not_see[d].add(c)

for i in range(n):
    print(size(i) - len(not_see[i]) - 1)
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


### FIXED CODE ###

x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if k>x: a=a[:k]
if k>y: b=b[:k]
if k>z: c=c[:k]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
d.sort(reverse=True)
if len(d)>k: d=d[:k]
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

from collections import deque, Counter
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7


def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    DP = [[0] * (N + 1) for _ in range(N + 1)]
    DP[1][1] = A[0]

    for i in range(2, N + 1):
        a = math.floor((i - 1) / 2)
        b = math.floor((i + 1) / 2)
        for j in range(a, b + 1):
            DP[i][j] = max(DP[i - 1][j], DP[i - 2][j - 1] + A[i - 1])
    print(int(DP[N][math.floor(N / 2)]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    @lru_cache(None)
    def f(i, j):
        if i < 0 or j < 0:
            return -INF
        if i == 0:
            return -INF
        if abs(j - i // 2 - 1) >= 2:
            return -INF
        if j == 0:
            return 0
        if j == 1:
            return max(A[:i])
        return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))

    print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# ABC139
def main():
    N, *A = map(int, open(0).read().split())
    B = {}
    for i in range(N):
        x = i * (N - 1)
        B[i + 1] = A[x : x + N - 1][::-1]
    ans, flg, matched = 0, 0, set()
    while B:
        for i in list(B.keys()):
            if i in B and i not in matched:
                x = B[i][-1]
                if x in B and x not in matched and B[x][-1] == i:
                    B[i].pop(), B[x].pop()
                    matched |= {i, x}
                    flg = 1
                    if B[i] == []:
                        del B[i]
                    if B[x] == []:
                        del B[x]
        if flg:
            ans += 1
            flg, matched = 0, set()
        else:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC139E - League
from collections import deque


def main():
    N, *A = map(int, open(0).read().split())
    B = {}
    for i in range(N):
        x = i * (N - 1)
        B[i + 1] = deque(A[x : x + N - 1])
    ans, cnt, matched = 0, 0, set()
    q = [i for i in range(1, N + 1)]
    while q:
        ans += 1
        next_q = []
        for i in q:
            if i in B and i not in matched:
                x = B[i][0]
                if x in B and x not in matched and B[x][0] == i:
                    B[i].popleft(), B[x].popleft()
                    matched |= {i, x}
                    cnt += 1
                    if not B[i]:
                        del B[i]
                    else:
                        next_q += [i]
                    if not B[x]:
                        del B[x]
                    else:
                        next_q += [x]
        q = next_q
        matched = set()
    flg = cnt == N * (N - 1) // 2
    print(ans if flg else -1)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import math
A, B, N = map(int,input().split())
x = [i for i in range(1,N+1)]
res = []
for i in range(N):
    ans = math.floor(A*x[i]/B) - (A*math.floor(x[i]/B))
    res.append(ans)
print(max(res))

### FIXED CODE ###

A, B, N = map(int,input().split())
x = min(B-1,N)
res = int(A*x/B) - (A*int(x/B))
print(res)
### BUGGY CODE ###

n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        if 2*j-i<n:
            k=2*j-i
            if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
                count0=count0+1
print(count-count0)

### FIXED CODE ###

n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,int((n+i-1)/2)+1):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)
### BUGGY CODE ###

n, m = map(int, input().split(" "))
towers = list(map(int, input().split(" ")))
roads = []
for i in range(m):
    roads.append(list(map(int, input().split(" "))))

total = 0
for i in range(n):
    for j in range(m):
        if roads[j][0] == i + 1:
            if towers[i] <= towers[roads[j][1] - 1]:
                break
        elif roads[j][1] == i + 1:
            if towers[i] <= towers[roads[j][0] - 1]:
                break
    else:
        total += 1
print(total)

### FIXED CODE ###

n,m=map(int, input().split(" "))
tower=list(map(int, input().split(" ")))
road=[list(map(int, input().split(" "))) for i in range(m)]
kosuu = [0 for i in range(n)]
temp = [0 for i in range(n)]
ans=0
for i in range(m):
  kosuu[road[i][0] - 1] += 1
  kosuu[road[i][1] - 1] += 1
for i in range(m):
  if tower[road[i][0] - 1] > tower[road[i][1] - 1]:
    temp[road[i][0] - 1] += 1
  elif tower[road[i][0] - 1] < tower[road[i][1] - 1]:
    temp[road[i][1] - 1] += 1
count = 0
for i in range(n):
  #print(n)
  if kosuu[i] == temp[i]:
    count += 1
print(count)
### BUGGY CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
                break
            elif check_tmp  == 2:
                continue
            for z in range(l_k):
                check_tmp =check3(x,y,z,l_s) 
                if check_tmp == 1:
                    break
#                print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

k,s=nyu()
print(calc(k+1,s))









### FIXED CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
#        check_tmp =0
#        check_tmp =check1(x,l_s,l_k)
#        if check_tmp == 1:
#            break
#        elif check_tmp  == 2:
#            continue
        for y in range(l_k):
#            check_tmp =check2(x,y,l_s,l_k)
#            if check_tmp == 1:
#                break
#            elif check_tmp  == 2:
#                continue2
#            sum = x+y+l_k 
            sum = l_s- x-y 
            if 0<=sum and sum <= k:
#                print("x=",x,"y="   ,y) 
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))