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

n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    ans = 0
    now = 0
    for p in a[:i] + a[i + 1:] + [0]:
        ans += abs(p - now)
        now = p
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

now = 0
d = []
for p in a + [0]:
    d.append(abs(p - now))
    now = p

a = [0] + a + [0]
sum_d = sum(d)
for i in range(n):
    ans = sum_d - (d[i] + d[i+1]) + abs(a[i] - a[i+2])
    print(ans)
### BUGGY CODE ###

n=int(input())
import itertools
from math import floor,sqrt
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      for z in range(1,floor(sqrt(m))+1):
        if x**2+y**2+z**2+x*y+y*z+z*x==m:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))

### FIXED CODE ###

n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
  sqset.add(i**2)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))
### BUGGY CODE ###

n,m,k=map(int, input().split( ))
F = [tuple(map(int, input().split( ))) for _ in range(m)]
B = [tuple(map(int, input().split( ))) for _ in range(k)]
Fx = [0 for i in range(n+1)]
Bx = [0 for i in range(n+1)]
for a,b in F:
    Fx[a]|=(1<<(b-1))
    Fx[b]|=(1<<(a-1))
for a,b in B:
    Bx[a]|=(1<<(b-1))
    Bx[b]|=(1<<(a-1))
#友達関係での連結成分で分解
#連結成分中から2つ選ぶ場合の数から友達関係とブロック関係を引く
#各人ごと
#https://tjkendev.github.io/procon-library/python/union_find/union_find.html
*p, = range(n+1)
rank = [1]*(n+1)
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    rx = rank[px]; ry = rank[py]
    if ry < rx:
        p[py] = px
    elif rx < ry:
        p[px] = py
    else:
        p[py] = px
        rank[px] += 1
    return 1
for a,b in F:
    unite(a,b)
dic = {}
for i in range(1,n+1):
    if root(i) in dic:
        dic[root(i)] |= 1<<(i-1)
    else:
        dic[root(i)] = 1<<(i-1)
for i in range(1,n+1):
    ans = dic[root(i)]&(-1^ (Fx[i]|Bx[i]))
    print(bin(ans).count("1")-1,end = " ")


### FIXED CODE ###

n,m,k=map(int, input().split( ))
F = [tuple(map(int, input().split( ))) for _ in range(m)]
B = [tuple(map(int, input().split( ))) for _ in range(k)]
Fx = [[] for i in range(n+1)]
Bx = [[] for i in range(n+1)]
for a,b in F:
    Fx[a].append(b)
    Fx[b].append(a)
for a,b in B:
    Bx[a].append(b)
    Bx[b].append(a)
#友達関係での連結成分で分解
#連結成分中から2つ選ぶ場合の数から友達関係とブロック関係を引く
#各人ごと
#https://tjkendev.github.io/procon-library/python/union_find/union_find.html
*p, = range(n+1)
rank = [1]*(n+1)
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    rx = rank[px]; ry = rank[py]
    if ry < rx:
        p[py] = px
    elif rx < ry:
        p[px] = py
    else:
        p[py] = px
        rank[px] += 1
    return 1
for a,b in F:
    unite(a,b)
dic = {}
for i in range(1,n+1):
    if root(i) in dic:
        dic[root(i)] +=1
    else:
        dic[root(i)] = 1
for i in range(1,n+1):
    ans = dic[root(i)]-1
    for b in Fx[i]:
        if root(b)==root(i):
            ans-=1
    for b in Bx[i]:
        if root(b)==root(i):
            ans-=1
    print(ans,end=" ")
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N
for i in range(1, N+1):
        for j in range(N):
                if(A[j] == i):
                        ans[i-1] = j+1
print(" ".join(map(str, ans)))

### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ans = [None]*N
for i, order in enumerate(A, 1):
        ans[order-1] = i
print(" ".join(map(str, ans)))
### BUGGY CODE ###

s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

# DPを逆に辿って復元する
ans = ""
i = len(s)
j = len(t)
while( i>=0 and j>=0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

print(ans)


### FIXED CODE ###

s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:    
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
           
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0 :
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] +ans
        i -= 1
        j -= 1
print(ans)
### BUGGY CODE ###

def pow(x, n):
    if n == 0:
        return 1
    value = pow(x, int(n / 2))
    value *= value
    if n % 2 == 1:
        value *= x
    return value


x = int(input())
li = [False] * (x + 1)
li[1] = True

for i in range(x):
    for j in range(2, x):
        idx = pow(i, j)
        if idx < x + 1:
            li[idx] = True

for i in reversed(range(x + 1)):
    if li[i]:
        print(i)
        break


### FIXED CODE ###

x = int(input())
li = [False] * (x + 1)
li[1] = True

for i in range(x):
    for j in range(2, x):
        if i ** j > x:
            break
        li[i ** j] = True

for i in reversed(range(x + 1)):
    if li[i]:
        print(i)
        break
### BUGGY CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n,m = MAP()
a = MAP()
heapify(a)
d = []
for i in range(m):
    b,c = MAP()
    d += [c]*b

d.sort(reverse=True)

while 1:
    tmp = heappop(a)
    if tmp<d[0]:
        heappush(a,d.pop(0))
    else:
        a+=[tmp]
        break
    if len(d)==0:
        break

print(sum(a))

### FIXED CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n, m = MAP()
a = MAP()
p = [(a[i], 1) for i in range(n)]
for j in range(m):
    b, c = MAP()
    p.append((c, b))
p.sort(reverse=True)
ans, cnt = 0, n
for (v, c) in p:
    use = min(c, cnt)
    ans += use * v
    cnt -= use
print(ans)
### BUGGY CODE ###

import math
H,N=map(int,input().split())
A=[]
B=[]
dp=[[0 for j in range(H)] for i in range(N)]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(N):
    for j in range(H):
        if i==0:
            dp[i][j]=B[i]*math.ceil((j+1)/A[i])
        elif j+1<=A[i]:
            dp[i][j]=min(dp[i-1][j],B[i])
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i])

print(dp[N-1][H-1])

### FIXED CODE ###

import math
H,N=map(int,input().split())
A=[0 for i in range(N)]
B=[0 for i in range(N)]
dp=[[0 for j in range(H)] for i in range(N)]
for i in range(N):
    A[i],B[i]=map(int,input().split())

for i in range(N):
    for j in range(H):
        if i==0:
            dp[i][j]=B[i]*math.ceil((j+1)/A[i])
        elif j+1<=A[i]:
            dp[i][j]=min(dp[i-1][j],B[i])
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i])

print(dp[N-1][H-1])
### BUGGY CODE ###

e=enumerate
n,a=open(0)
d=[0]+[-2**64]*2000
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[max(t-a*(~i-j+k+int(n)),d[k-1]-a*abs(~i+k))for k,t in e(d)]
print(max(d))

### FIXED CODE ###

e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))
### BUGGY CODE ###

a = list(map(int, input().split()))
a.sort()

cd = a[0]

while a[0]%cd != 0 or a[1]%a[0]%cd != 0:
    cd -= 1

print(cd)

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()

while a[0] > 0:
    b = a[1]%a[0]
    a[1] = a[0]
    a[0] = b
    
print(a[1])
### BUGGY CODE ###

n, m = map(int, input().split())
value = []
weight = []
for i in range(m):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    binary = 0
    for c in C:
        binary += 2**(c-1)
    value.append(A)
    weight.append(binary)
    
dp = [float("inf") for _ in range(2**n)]
dp[0] = 0
for s in range(2**n):
    for i in range(m):
        t = s | weight[i]
        cost = dp[s] + value[i]
        dp[t] = min(dp[t], cost)
if dp[2**n-1] == float("inf"):
    print(-1)
else:
    print(dp[2**n-1])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
 
n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))
    value.append([A, c])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        if dp[t] > cost:
            dp[t] = cost
        
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
from collections import deque

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

N = int(input())
que = deque([int(input()) for i in range(N)])
tmp = 0
max_num = max(set(que))

for i in range(N):
    tmp = que.popleft()
    if tmp != max_num:
        print(max_num)
    else:
        print(max(set(que)))
    que.append(tmp)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
from collections import deque

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

N = int(input())
que = deque([int(input()) for i in range(N)])
tmp = 0
max_num1 = sorted(que)[-1]
max_num2 = sorted(que)[-2]

for i in range(N):
    tmp = que.popleft()
    if tmp != max_num1:
        print(max_num1)
    else:
        print(max_num2)
    que.append(tmp)
### BUGGY CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    # MODを使わない普通のComb
    def choose(n, r):
        res = 1
        fac = 1
        for i in range(r):
            res *= n - i
            fac *= i + 1
        return res // fac

    s = input()

    l = len(s)

    cnt = [0 for _ in range(2019)]

    for i in range(l + 1):
        tmp = s[i:]
        if len(tmp) == 0:
            tmp = '0'
        tmp = int(tmp)
        tmp %= 2019
        cnt[tmp] += 1

    ans = 0
    for c in cnt:
        if c > 1:
            ans += c * (c - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()

    cnt = [0 for _ in range(2019)]
    cnt[0] += 1
    dec = 1
    num = 0
    for i in reversed(s):
        num += int(i) * dec
        num %= 2019
        dec *= 10
        dec %= 2019
        cnt[num] += 1

    ans = 0
    for c in cnt:
        ans += c * (c - 1) // 2

    print(ans)


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

a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
    ans = ans ^ i
    # print(bin(ans))
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
if a==0:
    print(b)
    exit()
ab = bin(a-1)[2:]
bb = bin(b)[2:]
# print(ab)
# print(bb)
sa = []
sb = []
if int(bb[-1]):
    sb = [1]
else:
    for i in bb:
        sb += [int(i)]
if a>0:
    if int(ab[-1]):
        sa = [1]
    else:
        for i in ab:
            # print(2)
            sa += [int(i)]
sa[-1] = (a//2)%2
sb[-1] = ((b+1)//2)%2
# print(sa)
# print(sb)
# print(ab)
ta = "".join([str(i) for i in sa])
tb = "".join([str(i) for i in sb])
ta = int(ta,2)
tb = int(tb,2)
# print(ta)
# print(tb)
ans = ta^tb
# print(ta)
# print(tb)
print(ans)
### BUGGY CODE ###

# D
import sys
sys.setrecursionlimit(100000)

hash_no = 10 ** 9 + 7
x, y = map(int, input().split())

counter = 0


def move(x, y, X, Y):
    global counter
    if (X + Y - x - y) % 3 != 0:
        return
    # if x >X:
    #     return
    # if y > Y:
    #     return
    if (x == X) and (y == Y):
        counter += 1
        return
    if Y > 2 * (X - x) + y:
        return
    if Y < (X - x) / 2 + y:
        return

    move(x + 1, y + 2, X, Y)
    move(x + 2, y + 1, X, Y)


move(0, 0, x, y)
print(counter % hash_no)

### FIXED CODE ###

# AtCoder Beginner Contest 145 D - Knight
import sys
from math import factorial

mod = 10 ** 9 + 7

X, Y = map(int, sys.stdin.readline().strip().split())

# 合計の移動回数は Total = X + Y / 3 
# 移動方法は A: (i + 1, j + 2)  B: (i + 2, j + 1) の2通り
# 移動回数は A: 2 * Total - X  B: X - Total 

# 到達不可能であるか判断する
if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

if Y > 2 * X or Y < X * 0.5:
    print(0)
    sys.exit()


Total = (X + Y) // 3
A = Total * 2 - X
B = X - Total

# combination の計算
ans = 1
for i in range(1, Total + 1):
    ans *= i
    ans %= mod

ans = ans * pow(factorial(A), mod - 2, mod)
ans = ans * pow(factorial(B), mod - 2, mod)

print(ans % mod)
### BUGGY CODE ###

a, b, c, k = map(int, input().split())

for _ in range(k):
        tmpA = a
        tmpB = b
        tmpC = c
        a = tmpB + tmpC
        b = tmpA + tmpC
        c = tmpB + tmpA

ans = a - b
if ans != 10**18:
    print(ans)
else:
    print("Unfair")

### FIXED CODE ###

a, b, c, k = map(int, input().split())

# for _ in range(k):
#         tmpA = a
#         tmpB = b
#         tmpC = c
#         a = tmpB + tmpC
#         b = tmpA + tmpC
#         c = tmpB + tmpA
#         if a - b >= 10**18:
#             print("Unfair")
#             exit()
# 
# print(a - b)
if a-b >= 10**18 or b-a >= 10**18:
    print("Unfair")
    exit()

if k%2 == 0:
    print(a-b)
else:
    print(b-a)
### BUGGY CODE ###

import sys
from itertools import accumulate
from collections import deque

def solve():
    N, K = map(int, input().split())
    S = input()
    q = deque([1 if c == 'A' else 0 for c in S])
    cb = 1

    for i in range(K):
        if q[0] == cb:
            q[0] ^= 1
            # cb ^= 1
        else:
            q.popleft()
            q.append(cb ^ 1)
            cb ^= 1

    # print(q)

    ans = ['A' if (c ^ cb ^ 1) else 'B' for c in q]
    print(''.join(ans))


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys
from itertools import accumulate
from collections import deque

def solve():
    N, K = map(int, input().split())
    S = input()

    '''
    if N == 1:
        if K % 2 == 0:
            print(S)
        else:
            print('A' if S == 'B' else 'B')

        return
    '''

    q = deque([1 if c == 'A' else 0 for c in S])
    cb = 0

    for i in range(min(K, 2 * N + K % 2)):
        if q[0] == (cb ^ 1):
            q[0] ^= 1
        else:
            q.popleft()
            q.append(cb)
            cb ^= 1

    # print(q)

    ans = ['A' if (c ^ cb) else 'B' for c in q]
    print(''.join(ans))


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

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

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    N, M, K = list(map(int, input().split()))
    U = UnionFind(N)
    FR = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        U.union(a - 1, b - 1)
        FR[a - 1] += 1
        FR[b - 1] += 1
    BL = [set() for _ in range(N)]
    for _ in range(K):
        c, d = map(int, input().split())
        BL[c - 1].add(d - 1)
        BL[d - 1].add(c - 1)
    LS = {}
    for i in range(N):
        t = U.find(i)
        if t not in LS:
            LS[t] = set()
        LS[t].add(i)

    print(' '.join(str(len(LS[U.find(i)] - BL[i]) - 1 - FR[i]) for i in range(N)))

main()


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    N, M, K = list(map(int, input().split()))
    U = UnionFind(N)
    FR = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        U.union(a - 1, b - 1)
        FR[a - 1] += 1
        FR[b - 1] += 1
    r = [0] * N
    LS = {}
    for i in range(N):
        t = U.find(i)
        if t not in LS:
            LS[t] = set()
        LS[t].add(i)
        r[i] = -U.parents[t] - 1 - FR[i]
    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c - 1, d - 1
        if d in LS[U.find(c)]:
            r[c] -= 1
            r[d] -= 1
    print(' '.join(str(i) for i in r))

main()
### BUGGY CODE ###

S = input()

A = [0]

for i in range(len(S)):
    if S[i] == '<':
        A.append(A[i]+1)
    else:
        A.append(0)
    if A[i+1] < 0:
        A[i+1] += 1
    for j in reversed(range(i+1)):
        if S[j] == '<':
            if A[j] >= A[j+1]:
                A[j]-=1
        elif S[j] == '>':
            if A[j] <= A[j+1]:
                A[j]+=1

print(sum(A))



### FIXED CODE ###

S = input()
a = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
for i in reversed(range(len(S))):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1]+1)
ans = sum(a)

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

import math
h, w, a, b = map(int, input().split(" "))
count = 0
for inter_h in range(h - a):
    molec = math.factorial(b - 1 + inter_h)
    denom = math.factorial(b - 1) * math.factorial(inter_h)
    comb_1 = molec // denom
    molec = math.factorial(w - b - 1 + h - inter_h - 1)
    denom = math.factorial(w - b - 1) * math.factorial(h - inter_h - 1)
    comb_2 = molec // denom
    count += (comb_1 * comb_2) % (10 ** 9 + 7)
rem = count % (10 ** 9 + 7)
print(rem)

### FIXED CODE ###

h, w, a, b = map(int, input().split(" "))
div = 10 ** 9 + 7
size = h + w - 1

fact = [0] * size
inverse = [0] * size
inv_calced = [0] * size
fact[:2] = [1, 1]
inverse[:2] = [1, 1]
inv_calced[:2] = [0, 1]

for i in range(2, size):
  fact[i] = fact[i - 1] * i % div
  inv_calced[i] = -inv_calced[div % i] * (div // i) % div
  inverse[i] = inverse[i - 1] * inv_calced[i] % div
  
result = 0
for x in range(b, w):
  y = h - a - 1
  temp_1 = (fact[x+y] * inverse[x] % div) * inverse[y] % div
  temp_2 = (fact[h+w-x-y-3] * inverse[w-x-1] % div) * inverse[h-y-2] % div
  result += ((temp_1 % div) * (temp_2 % div)) % div

print(result % div)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

ans = []
for x in range(1, n):
  y = n - x
  dis = abs(sum(a[:x]) - sum(a[x:]))
  ans.append(dis)

print(min(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

total = sum(a)
ans = []
for x in range(n-1):
  total -= 2*a[x]
  ans.append(abs(total))

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

L = []
S = str(input())
Q = int(input())
Ql = [[] for _ in range(Q)] 

for i in range(len(S)):
    L.append(S[i])

for i in range(Q):
    A = input().split()
    Ql[i] = A

for i in range(Q):
    if Ql[i][0] == '1':
        L.reverse()
            
    elif Ql[i][0] == '2':
        if Ql[i][1] == '1':
            L.insert(0, Ql[i][2])
        else:
            L.append(Ql[i][2])

print(''.join(L))

### FIXED CODE ###

from collections import deque

L = deque([])
S = str(input())
q = int(input())
Q = [[] for _ in range(q)] 

for i in range(len(S)):
    L.append(S[i])

for i in range(q):
    A = input().split()
    Q[i] = A

num = 0

for i in range(q):
    if Q[i][0] == '1':
        num ^= 1
    if Q[i][0] == '2':
        if num == 0:
            if Q[i][1] == '1':
                L.appendleft(Q[i][2])
            else:
                L.append(Q[i][2])
        else:
            if Q[i][1] == '2':
                L.appendleft(Q[i][2])
            else:
                L.append(Q[i][2])

if num:
    L.reverse()

print(''.join(L))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
g = [[] for _ in range(n)] # 隣接リスト

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

# 0からの各頂点の距離
d = bfs(0)
print('Yes')
for i in range(n - 1):
    print(d.index((d[i + 1]) - 1) + 1)

### FIXED CODE ###

n, m = map(int, input().split())
g = [[] for _ in range(n)] # 隣接リスト

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = v
                queue.append(i)
    return d

# 0からの各頂点の距離
d = bfs(0)
print('Yes')
for i in range(1, n):
    print(d[i] + 1)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += a[i] ^ a[j]
        ans %= MOD
print(ans)


### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))
    M = max(A)
    dig = len(bin(M)) - 2
    MOD = 10 ** 9 + 7
    ans = 0
    d = {i: [0, 0] for i in range(dig)}
    for a in A:
        a = bin(a)[2:].zfill(dig)
        for i in range(len(a)):
            if a[-(i+1)] == '0':
                d[i][0] += 1
            else:
                d[i][1] += 1
    for i in range(dig):
        ans += d[i][0] * d[i][1] * pow(2, i, MOD)
        ans %= MOD
    print(ans)
main()