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

import sys
input = sys.stdin.readline
#import heapq
from collections import deque

H,W = map(int, input().split())
Ch,Cw = map(int, input().split())
Dh,Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

S = []
for _ in range(H):
  S.append(list(input()))
  
dpat = ((-1,0),(1,0),(0,-1),(0,1))
mpat = []
for i in range(-2,3):
  for j in range(-2,3):
    if (i,j) in dpat:
      continue
    if i == j and j == 0:
      continue
    mpat.append((i,j))
                
#print(mpat)

#BFS
visited = [[False] * W for _ in range(H)]
willSearch = [[False] * W for _ in range(H)]
Q = deque()
QN = deque()
Q.append((0,Ch,Cw))
QN.append((0,Ch,Cw))
while Q:
  while Q:
    c,x,y = Q.popleft()
    if visited[x][y]:
      continue
    visited[x][y] = True
    QN.append((c,x,y))
    #print(c,x,y)
    if x == Dh and y == Dw:
      print(c)
      exit(0)
    for dx,dy in dpat:
      nx,ny = x+dx, y+dy
      if 0<=nx<H and 0<=ny<W:
        if S[nx][ny] == "#":
          continue
        if visited[nx][ny] or willSearch[nx][ny]:
          continue
        Q.append((c,nx,ny))
        QN.append((c,nx,ny))
        willSearch[nx][ny] = True
  while QN:
    c,x,y = QN.popleft()
    for dx,dy in mpat:
      nx,ny = x+dx, y+dy
      if 0<=nx<H and 0<=ny<W:
        if S[nx][ny] == "#":
          continue
        if visited[nx][ny] or willSearch[nx][ny]:
          continue
        Q.append((c+1,nx,ny))
        #print("m", c+1, nx,ny)
        #willSearch[nx][ny] = True
      
print(-1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
#import heapq
from collections import deque

H,W = map(int, input().split())
Ch,Cw = map(int, input().split())
Dh,Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

S = []
for _ in range(H):
  S.append(list(input()))
  
dpat = ((-1,0),(1,0),(0,-1),(0,1))
mpat = []
for i in range(-2,3):
  for j in range(-2,3):
    if (i,j) in dpat:
      continue
    if i == j and j == 0:
      continue
    mpat.append((i,j))
                
#print(mpat)

#BFS
visited = [[False] * W for _ in range(H)]
willSearch = [[False] * W for _ in range(H)]
Q = deque()
QN = deque()
Q.append((0,Ch,Cw))
QN.append((0,Ch,Cw))
while Q:
  while Q:
    c,x,y = Q.popleft()
    if visited[x][y]:
      continue
    visited[x][y] = True
    QN.append((c,x,y))
    #print(c,x,y)
    if x == Dh and y == Dw:
      print(c)
      exit(0)
    for dx,dy in dpat:
      nx,ny = x+dx, y+dy
      if 0<=nx<H and 0<=ny<W:
        if S[nx][ny] == "#":
          continue
        if visited[nx][ny] or willSearch[nx][ny]:
          continue
        Q.append((c,nx,ny))
        QN.append((c,nx,ny))
        willSearch[nx][ny] = True
  while QN:
    c,x,y = QN.popleft()
    for dx,dy in mpat:
      nx,ny = x+dx, y+dy
      if 0<=nx<H and 0<=ny<W:
        if S[nx][ny] == "#":
          continue
        if visited[nx][ny] or willSearch[nx][ny]:
          continue
        Q.append((c+1,nx,ny))
        #print("m", c+1, nx,ny)
        #willSearch[nx][ny] = True
      
print(-1)
### BUGGY CODE ###

a,b,x = map(int,input().split())
ans = 0
for i in range(a,b+1):
  if i % x == 0:
    ans += 1
  else:
    continue
print(ans)

### FIXED CODE ###

a,b,x = map(int,input().split())
print(b//x-(a-1)//x)
### BUGGY CODE ###

import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    H,W = map(int, input().split())
    grid = [list(input().rstrip()) for _ in range(H)]
    q = []
    visited = [[False]*W for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if grid[y][x] == '#':
                q.append((y,x))
                visited[y][x] = True
    ans = -1
    while q:
        ans += 1
        new_q = []
        for y,x in q:
            for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
                ny = y+dy
                nx = x+dx
                if 0<=ny<H and 0<=nx<W and not visited[ny][nx] and grid[ny][nx] == '.':
                    new_q.append((ny,nx))
                    visited[ny][nx] = True
        if new_q:
            q = new_q
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    H, W = map(int,input().split())
    visited = [[False]*W for _ in range(H)]
    q = []
    for y in range(H):
        S = input()
        for x, s in enumerate(S):
            if s == "#":
                q.append((y, x))
                visited[y][x] = True

    ans = -1
    while q:
        ans += 1
        nq = []
        for y, x in q:
            if 0 < x and not visited[y][x-1]:
                visited[y][x-1] = True
                nq.append((y,x-1))
            if x < W-1 and not visited[y][x+1]:
                visited[y][x+1] = True
                nq.append((y,x+1))
            if 0 < y and not visited[y-1][x]:
                visited[y-1][x] = True
                nq.append((y-1, x))
            if y < H-1 and not visited[y+1][x]:
                visited[y+1][x] = True
                nq.append((y+1,x))
        if nq:
            q = nq
        else:
            break

    print(ans)

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

#!/usr/bin/env python3
import sys


def solve(N: int, T: "List[int]", V: "List[int]"):
    t_period = [0 for i in range(N+1)]
    for i in range(N):
        t_period[i+1] = t_period[i] + T[i]*2

    limit = [0 for t in range(t_period[N]+1)]
    for i in range(1, N):
        limit[t_period[i]] = min((V[i-1], V[i]))
    for i in range(N):
        limit[t_period[i]+1:t_period[i+1]] = [V[i]] * (t_period[i+1] - t_period[i] - 1)
    
    speed = [0 for t in range(t_period[N]+1)]

    for v in range(1, 201):
        for t in range(1, t_period[N]):
            speed[t] = min([limit[t], speed[t-1]+0.5, speed[t+1]+0.5])

    total = 0
    for t in range(t_period[N]):
        total += (speed[t] + speed[t+1]) * 0.5 * 0.5
    
    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, t, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, T: "List[int]", V: "List[int]"):
    t_period = [0 for i in range(N+1)]
    for i in range(N):
        t_period[i+1] = t_period[i] + T[i]*2

    limit = np.zeros((t_period[N]+1,))
    for i in range(1, N):
        limit[t_period[i]] = min((V[i-1], V[i]))
    for i in range(N):
        limit[t_period[i]+1:t_period[i+1]] = V[i]
    
    speed = np.zeros((t_period[N]+1,))

    for v in range(1, 201):
        speed[1:t_period[N]] = np.min([limit[1:t_period[N]], speed[0:t_period[N]-1]+0.5, speed[2:t_period[N]+1]+0.5], axis=0)

    total = 0
    for t in range(t_period[N]):
        total += (speed[t] + speed[t+1]) * 0.5 * 0.5
    
    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, t, v)

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

import copy
H,W=map(int,input().split())


MAP=[["." for i in range (W+2)]for i in range(H+2)]
tMAP=[["." for i in range (W+2)]for i in range(H+2)]

for i in range(H):
    A=list(input())
    for j in range(W):
        MAP[i+1][j+1]=A[j]
tMAP=copy.deepcopy(MAP)

c=0
while(True):
    k=0
    for i in range(1,H+1):
        for j in range(1,W+1):
            if(MAP[i][j]=="."):
                k=1
    if(k==0):
        break
    c+=1
    for i in range(1,H+1):
        for j in range(1,W+1):
            if(MAP[i][j]=="#"):
                tMAP[i-1][j]="#"
                tMAP[i+1][j]="#"
                tMAP[i][j-1]="#"
                tMAP[i][j+1]="#"
    MAP=copy.deepcopy(tMAP)
print(c)

### FIXED CODE ###

H,W=map(int,input().split())

MAP=[["." for i in range (W)]for i in range(H)]
LIST=[0]*(10**6+100)

l=0
r=0
for i in range(H):
    A=list(input())
    for j in range(W):
        if(A[j]=="#"):
            MAP[i][j]="#"
            LIST[r]=(i,j,0)
            r+=1

while(True):
    T=LIST[l]
    i=T[0]
    j=T[1]
    if(i>0):
        if(MAP[i-1][j]=="."):
            MAP[i-1][j]="#"
            LIST[r]=(i-1,j,T[2]+1)
            r+=1  
    if(i+1<H):
        if(MAP[i+1][j]=="."):
            MAP[i+1][j]="#"
            LIST[r]=(i+1,j,T[2]+1)
            r+=1  
    if(j>0):
        if(MAP[i][j-1]=="."):
            MAP[i][j-1]="#"
            LIST[r]=(i,j-1,T[2]+1)
            r+=1  
    if(j+1<W):
        if(MAP[i][j+1]=="."):
            MAP[i][j+1]="#"
            LIST[r]=(i,j+1,T[2]+1)
            r+=1
    l+=1
    if(r<=l):
        print(LIST[r-1][2])
        exit()
### BUGGY CODE ###

from fractions import gcd
from itertools import combinations, chain

def gcd_all(numbers):
  gcds = numbers.__next__()
  for x in numbers:
    gcds = gcd(gcds, x)
  return gcds

def main():
  N = int(input().strip())
  A = list(map(int, input().strip().split()))
  
  gcds = []
  for i in range(N):
    gcds.append(gcd_all(chain(A[:i], A[i+1:])))
  
  print(max(gcds))
 
if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
import math
from fractions import gcd
import operator
from functools import reduce
from itertools import accumulate

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def prime_factorization_preprocess(n):
    """
    エラトステネスの篩を用いて、sqrt(n)以下の素数を列挙する
    """
    m = math.floor(math.sqrt(n)) + 1
    primes = []
    is_prime = [True for i in range(m)]
    for i in range(2, m):
        if is_prime[i]:
            primes.append(i)
            for j in range(i+i, m, i):
                is_prime[j] = False
    return primes


def prime_factorization(x, primes):
    """
    試し割り法により、数値の素因数分解を求める
    """
    factors = defaultdict(int)
    for p in primes:
        if x % p == 0:
            n = 0
            while x % p == 0:
                x //= p
                n += 1
            factors[p] = n
    return factors


def solve(N, A, AMAX = 10**9, INF=10**9):
    sl = list(accumulate(A, gcd))
    sr = list(reversed(list(accumulate(reversed(A), gcd))))
    max_gcd = sl[-1]
    for i in range(N):
        # gcdの単位元は0
        v = 0
        if i > 0:
            v = gcd(v, sl[i-1])
        if i < N-1:
            v = gcd(v, sr[i+1])
        max_gcd = max(max_gcd, v)
    return max_gcd


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

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

for i in range(N):
  List.append(A.index(i+1)+1)

L = [str(a) for a in List]
L = ' '.join(L)
print(L)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
List = [0]*N


for i, a in enumerate(A):
  List[int(a)-1] = str(i+1)

  
print(" ".join(List))
### BUGGY CODE ###

from sys import stdin
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:return y
    else:
        while(x%y!=0):
            z=x%y
            x=y
            y=z
        return z

K = list(map(int, (stdin.readline().strip().split())))[0]
ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans+=gcd(i,gcd(j,k))
print(ans)

### FIXED CODE ###

from sys import stdin
import itertools
from math import gcd
# def gcd(a,b):
#     x=max(a,b)
#     y=min(a,b)
#     if x%y==0:return y
#     else:
#         while(x%y!=0):
#             z=x%y
#             x=y
#             y=z
#         return z

# K = list(map(int, (stdin.readline().strip().split())))[0]
# i=[x for x in range(1,K+1)]
# j=[x for x in range(1,K+1)]
# k=[x for x in range(1,K+1)]
# num_list=set(map(tuple,(sorted(x) for x in (itertools.product(i,j,k)))))
#
# ans=0
# for i,j,k in num_list:
#     if i==j:
#         if j==k:
#             ans+=K
#         else:
#             ans+=gcd(i,gcd(j,k))*3
#     elif j==k:ans+=gcd(i,gcd(j,k))*3
#     else:ans+=gcd(i,gcd(j,k))*6
K = int(input())

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        k = gcd(i, j)
        for l in range(1, K + 1):
            a = gcd(k, l)
            ans += a
print(ans)
### BUGGY CODE ###

from collections import Counter

s = list(input())
ls = len(s)
T = [0] * (ls+1)
modL = [0]
cnt = 0

for i in range(0, ls):
    j = ls-i-1
    T[j] = T[j+1] + int(s[j]) * 10**(i)
    modL.append(T[j] % 2019)

ans = 0
modC = Counter(modL)
for c in modC.values():
    ans += c * (c - 1) // 2

print(ans)


### FIXED CODE ###

from collections import Counter

s = list(input())
ls = len(s)
T = [0] * (ls+1)
modL = [0]
cnt = 0
pad = 1

for i in reversed(range(0, ls)):
    T[i] = T[i+1] + int(s[i]) * pad
    modL.append(T[i] % 2019)
    pad = pad * 10 % 2019

ans = 0
for c in Counter(modL).values():
    ans += c * (c - 1) // 2

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

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
K, S = map(int,F.readline().split())
count = 0
for x in range(K+1):
    yplusz = S - x
    for y in range(yplusz+1):
        z = yplusz - y
        if z <= K and y <= K:
            count += 1

print(count)


### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
K, S = map(int,F.readline().split())
count = 0
for x in range(K+1):
    yplusz = S - x
    for y in range(yplusz+1):
        z = yplusz - y
        if z <= K and y <= K:
            count += 1

print(count)
### BUGGY CODE ###

r,c,k = list(map(int, input().split()))

dp=[[[0]*4 for _ in range(c)] for _ in range(r)]


F = [[0]*c for _ in range(r)]

for _ in range(k):
  x,y,v = list(map(int, input().split()))
  x-=1
  y-=1
  F[x][y] = v
  
for i in range(r):
  for j in range(c):

    val = F[i][j]
  
      
    mxv = max(dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3],0)

    dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + val)
    dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + val)
    dp[i][j][1] = max(dp[i][j-1][1], dp[i][j-1][0] + val, mxv + val)
    dp[i][j][0] = mxv

best = 0

for j in range(c-1,c):
  for k in range(4):
    best = max(best, dp[-1][j][k])
    
print(best)

### FIXED CODE ###

r,c,k = list(map(int, input().split()))
import copy
dp=[[[0]*4 for _ in range(c)] for _ in range(2)]


F = [[0]*c for _ in range(r)]

for _ in range(k):
  x,y,v = list(map(int, input().split()))
  x-=1
  y-=1
  F[x][y] = v
  
for nn in range(r):
  for j in range(c):
    i = 1
    val = F[nn][j]
  
      
    mxv = max(dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3],0)

    dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + val)
    dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + val)
    dp[i][j][1] = max(dp[i][j-1][1], dp[i][j-1][0] + val, mxv + val)
    dp[i][j][0] = mxv

  dp[0] = dp[1] 
  dp[1] = [[0]*4 for _ in range(c)]

best = 0


for k in range(4):
  best = max(best, dp[0][c-1][k])
    
print(best)
### BUGGY CODE ###

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

cnt = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if A[i] < B[j] < C[k]:
        cnt = cnt + 1

print(cnt)

### FIXED CODE ###

import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

cnt = 0
for j in range(N):
  target = B[j]
  insert_indexA = bisect.bisect_left(A, target)
  insert_indexC = bisect.bisect_right(C, target)
  cnt = cnt + insert_indexA * (len(C)-insert_indexC)

print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
S = input()
lr = [[int(i) for i in input().split()] for i in range(Q)]
C = []
for i in range(N-1):
    if S[i] == "A":
        if S[i+1] == "C":
            C.append(i)
for l,r in lr:
    AC = 0
    for j in C:
        if j >= l-1:
            if j < r-1:
                AC += 1
            else:
                break
    print(AC)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
S = input()
lr = [[int(i) for i in input().split()] for i in range(Q)]
C = [0]*(N+1)
terget = "AC"
index = -1
for i in range(N):
    C[i+1] = C[i] + (S[i:i+2] == "AC")
for l,r in lr:
    print(C[r-1] - C[l-1])
### BUGGY CODE ###

S = list(input())
Q = int(input())
Query = []
cnt_re = 0
for i in range(Q):
  tmp = input().split()
  Query.append(tmp)
  if (len(tmp) == 1):
    cnt_re += 1
prev = ''
after = ''
if (cnt_re % 2 != 0):
  S = list(reversed(S))
for q in Query:
  if (len(q) == 3):
    if q[1] == '1':
      if (cnt_re % 2 == 0):
        prev = q[2] + prev
      else:
        after = after + q[2]
    else:
      if (cnt_re % 2 == 0):
        after = after + q[2]
      else:
        prev = q[2] + prev
  else:
    cnt_re -= 1
print(prev + ''.join(list(S)) + after)

### FIXED CODE ###

from collections import deque

S = list(input())
Q = int(input())
Query = []
cnt_re = 0
for i in range(Q):
    tmp = input().split()
    Query.append(tmp)
    if (len(tmp) == 1):
        cnt_re += 1
prev = deque()
after = deque()
if (cnt_re % 2 != 0):
    S = list(reversed(S))
for q in Query:
    if (len(q) == 3):
        if q[1] == '1':
            if (cnt_re % 2 == 0):
                prev.appendleft(q[2])
            else:
                after.append(q[2])
        else:
            if (cnt_re % 2 == 0):
                after.append(q[2])
            else:
                prev.appendleft(q[2])
    else:
        cnt_re -= 1
print(''.join(list(prev)) + ''.join(list(S)) + ''.join(list(after)))
### BUGGY CODE ###

s = list(input())
c = 0
while s:
  if s[0] == s[-1]:
    s = s[1:-1]
  else:
    if s[0] == "x":
      s += ["x"]
      c += 1
    elif s[-1] == "x":
      s = ["x"] + s
      c += 1
    else:
      print(-1)
      exit()
print(c)

### FIXED CODE ###

#!/usr/bin/env python3
s = input()
l, r = 0, len(s) - 1
c = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        c += 1
    elif s[r] == "x":
        r -= 1
        c += 1
    else:
        print(-1)
        exit()
print(c)
### BUGGY CODE ###

#!/usr/bin/python3
import sys
import queue

# main
q = queue.PriorityQueue()
m = 2 * (10 ** 9)
while True:
    s = sys.stdin.readline().split()
    if s[0].startswith('i'):
        q.put(m - int(s[1]))
    elif s[0].startswith('ex'):
        print(m - q.get())
    if s[0] == 'end':
        exit()

### FIXED CODE ###

#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
    
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

# v: node, p: parent node, add: parent value
def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])
 
dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

for i in range(N):
    A[i] = A[i] % (1e9 + 7)

sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum += A[i]*A[j] % (1e9 + 7)

print(int(sum % (1e9 + 7)))



### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
mod = int(1e9+7)

sum = 0
row = 0
for ii in range(N-1):
    i = N-2-ii
    row += A[i+1]
    row %= mod
    sum += A[i] * row
    sum %= mod

print(sum)
### BUGGY CODE ###

ans = 1
for k in range(1, int(input())+1):
    ans *= k
print(ans % (10**9+7))

### FIXED CODE ###

from math import factorial
print(factorial(int(input())) % (10**9+7))
### BUGGY CODE ###

import sys

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

    MOD = pow(10, 9) + 7

    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    B = A[::-1]
    fact = [1]
    for i in range(1, n+1):
        fact.append((fact[i-1]*i)%MOD)
    now = k-2
    S = []
    while now <= n-2:
        tmp = ((fact[now] % MOD * pow(fact[now-(k-2)], MOD-2, MOD)) % MOD * pow(fact[k-2], MOD-2, MOD)) % MOD
        S.append(tmp)
        now += 1

    ans = 0
    for i, a in enumerate(A):
        now = k-2
        j = 0
        while now <= n-2-i:
            tmp = S[j]
            ans = (ans - a*tmp)%MOD
            now += 1
            j += 1

    for i, b in enumerate(B):
        now = k-2
        j = 0
        while now <= n-2-i:
            tmp = S[j]
            ans = (ans + b*tmp)%MOD
            now += 1
            j += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

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

    MOD = pow(10, 9) + 7

    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    B = A[::-1]
    fact = [1]
    for i in range(1, n+1):
        fact.append((fact[i-1]*i)%MOD)
    now = k-2
    S = []
    while now <= n-2:
        tmp = ((fact[now] % MOD * pow(fact[now-(k-2)], MOD-2, MOD)) % MOD * pow(fact[k-2], MOD-2, MOD)) % MOD
        S.append(tmp)
        now += 1
    cumsum = [0, ]
    for i, s in enumerate(S):
        cumsum.append((cumsum[i]+s) % MOD)
    ans = 0
    for i, a in enumerate(A):
        ans = (ans - a*cumsum[-(i+1)])%MOD
        if cumsum[-(i+1)] == 0:
            break
    for i, b in enumerate(B):
        ans = (ans + b*cumsum[-(i+1)])%MOD
        if cumsum[-(i+1)] == 0:
            break
    print(ans)


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

N,X,Y = list(map(int, input().split()))
inf = float('inf')

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

for i in range(1,N+1):
    for j in range(i+1,N+1):
        dp[i][j] = min(j-i,abs(j-Y)+abs(i-X)+1)

for j in range(1,N):
    ans = 0
    for k in range(N+1):
        ans += dp[k].count(j)
    print(ans)



### FIXED CODE ###

N,X,Y = list(map(int, input().split()))

ans = [0]*(N+1)

for i in range(1,N+1):
    for j in range(i+1,N+1):
        ans[min(j-i,abs(j-Y)+abs(i-X)+1)] += 1

for j in range(1,N):
    print(ans[j])