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

import math

def is_prime(n: int)-> bool:
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    # when n is a prime number
    # x^(n-1) ≡ 1 (mod n)
    return pow(2, (n-1), n) == 1


def prime_factorize(n: int):
    prime_factors = []

    for i in range(2, n+1):
        if not is_prime(i):
            continue
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors.append(i)
                n = div
            else:
                break
        if n == 1:
            break
    return prime_factors


def main():
    N, P = map(int, input().split())
    prime_factors = prime_factorize(P)

    gcd = 1
    for i in set(prime_factors):
        i_count = prime_factors.count(i) // N
        gcd *= pow(i, i_count)

    print(gcd)
    return

main()

### FIXED CODE ###

import math
from collections import defaultdict

def is_prime(n: int)-> bool:
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    # when n is a prime number
    # x^(n-1) ≡ 1 (mod n)
    return pow(2, (n-1), n) == 1


def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime(i):
            continue
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
    N, P = map(int, input().split())
    prime_factors = prime_factorize(P)

    gcd = 1
    for k, v in prime_factors.items():
        v_cnt = v // N
        gcd *= pow(k, v_cnt)

    print(gcd)
    return

main()
### BUGGY CODE ###

INF = 10**9
n, m = map(int, input().split())
dp = [INF]*(2**n)
dp[0] = 0
for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    tmp = [INF]*(2**n)
    for j in range(2**n):
        tmp[j] = min(tmp[j], dp[j])
        tmp[j|c] = min(tmp[j|c], dp[j]+a)
    dp = tmp

print(dp[-1] if dp[-1]<INF else -1)


### FIXED CODE ###

INF = 10**9
n, m = map(int, input().split())
keys = []
for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    keys.append((a, c))

dp = [INF]*(2**n)
dp[0] = 0
for a, c in keys:
    tmp = [INF]*(2**n)
    for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
    dp = tmp

print(dp[-1] if dp[-1]<INF else -1)
### BUGGY CODE ###

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)なるxを返す
def modinv(a):
    (inv, q, gcd_val) = egcd(a, MOD)
    return inv % MOD

MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
c=1
a_m=0
a_M=0
for i in range(n-k,-1,-1):
    a_m+=a[i]*c
    a_m%=MOD
    a_M+=a[n-1-i]*c
    a_M%=MOD
    c=c*(n-i)*modinv(n-k+1-i)

ans=(a_M-a_m+MOD)%MOD
print(ans)

### FIXED CODE ###

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)なるxを返す
def modinv(a):
    (inv, q, gcd_val) = egcd(a, MOD)
    return inv % MOD

MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
c=1
a_m=0
a_M=0
for i in range(n-k,-1,-1):
    a_m+=a[i]*c
    a_m%=MOD
    a_M+=a[n-1-i]*c
    a_M%=MOD
    c=( c*(n-i)*modinv(n-k+1-i) )%MOD

ans=(a_M-a_m+MOD)%MOD
print(ans)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

N =  int(readline())
HP = [tuple(map(int, readline().split())) for _ in range(N)]
HP.sort(key = lambda x: x[0] + x[1])
INF = 1<<64

dp = [0]
for i in range(N):
    hi, pi = HP[i]
    dp2 = dp[:] + [INF]
    for j in range(i+1):
        if dp[j] > hi:
            break
        dp2[j+1] = min(dp2[j+1], dp[j]+pi)

    dp = dp2[:]

for ans in range(N+1):
    if dp[ans] == INF:
        ans -= 1
        break
print(ans)



### FIXED CODE ###

import sys
readline = sys.stdin.readline

N =  int(readline())
HP = [tuple(map(int, readline().split())) for _ in range(N)]
HP.sort(key = lambda x: x[0] + x[1])
INF = 1<<64

dp = [0]
for i in range(N):
    hi, pi = HP[i]
    dp += [INF]
    for j in range(i+1, 0, -1):
        if dp[j-1] > hi:
            continue
        dp[j] = min(dp[j], dp[j-1]+pi)
for ans in range(N+1):
    if dp[ans] == INF:
        ans -= 1
        break
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

import numpy as np

d = [0] * n

if k >= n:
    k = (n - 1)

for i in range(1, k):
    d[i] = min([d[j]+np.abs(h[i]-h[j]) for j in range(i)])

for i in range(n-k):
    d[i+k] = min([d[i+j]+np.abs(h[i+k]-h[i+j]) for j in range(k)])

print(d[n-1])

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))
### BUGGY CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    while a[i] + a[i + 1] > x:
        if a[i + 1] == 0:
            ans += 1
            a[i] -= 1
        else:
            ans += 1
            a[i + 1] -= 1
print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        ans += a[i + 1] + a[i] - x
        a[i + 1] = x - a[i]
        if a[i + 1] < 0:
            a[i + 1] = 0
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
arr = [abs(x[i] - x[i + 1]) for i in range(m-1)]
for _ in range(n - 1):
    if len(arr) <= 0:
        break
    arr.remove(max(arr))

print(sum(arr))

### FIXED CODE ###

n, m = map(int, input().split())
x = sorted(map(int, input().split()))
arr = [x[i + 1] - x[i] for i in range(m - 1)]
arr.sort(reverse=True)
print(sum(arr[n-1:]))
### BUGGY CODE ###

n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tar=str(i)+str(j)+str(k)
            now=0
            for l in range(n):
                
                if tar[0+now]==s[l]:now+=1
                if now==3:
                    ans+=1
                    break
print(ans)                    

### FIXED CODE ###

n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tar=str(i)+str(j)+str(k)
            now=0
            for l in range(n):
                
                if tar[0+now]==s[l]:now+=1
                if now==3:
                    ans+=1
                    break
print(ans)
### BUGGY CODE ###

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v.append('-')
        tmp = []
        nc = ''
        nn = 0
        for c in v:
            if nc == '':
                nc = c
                nn += 1
                continue
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = ''
        nn = 0
        for i in range(h+1):
            if i == h:
                c = '-'
            else:
                c = s[i][j]
            if nc == '':
                nc = c
                nn += 1
                continue
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)


### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v = v + '-'
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h):
            c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        if nc == '#':
            tmp.extend([0 for _ in range(nn)])
        else:
            tmp.extend( [nn for _ in range(nn)])
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)
### BUGGY CODE ###

import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)
m ={}
def f(n , r):
    if (n, r) in m:
        return m[(n,r)]
    if (n < r):
        return 0
    tmp = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    m[(n, r)] = tmp
    return tmp


total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1, 2))

### FIXED CODE ###

import collections
import functools
import math

n = int(input())
l = list(map(int, input().split(" ")))
c = collections.Counter(l)
m ={}
def f(n , r):
    if (n, r) in m:
        return m[(n,r)]
    if (n < r):
        return 0
    tmp = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    m[(n, r)] = tmp
    return tmp


total = functools.reduce(lambda x, y : x + f(y, 2), c.values(), 0)

for i in l:
    print(total - f(c.get(i, 0), 2) + f(c.get(i, 0) - 1, 2))
### BUGGY CODE ###

n = int(input())
s = input()

dp = [[0 for j in range(n+1)] for i in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(1,n):
        if s[i] == s[j] and i+dp[i][j]+1 <= j:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+1)
        else:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])

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

### FIXED CODE ###

n = int(input())
s = input()

ans = 0
right = 1

for left in range(n):
    while s[left:right] in s[right:]:
        ans = max(ans,right-left)
        right += 1
        
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())
cou = 1
frt = ""
bck = ""
for i in range(q):
    t = list(input().split())
    #logging.debug(t)#
    if t[0] == "1":
        cou *= -1
    else:
        if (t[1] == "1" and cou == 1)or(t[1] == "2" and cou == -1):
            s = t[2] + s
        else:
            s = s + t[2]
#    logging.debug("s {},cou {}".format(s,cou))

#s = frt + s + bck
#logging.debug(s)#
if cou == 1:
    print(''.join(s))
else:
    print(''.join(s[::-1]))

### FIXED CODE ###

s = input()
q = int(input())
cou = 1
frt = ""
bck = ""
for i in range(q):
    t = list(input().split())
    #logging.debug(t)#
    if t[0] == "1":
        cou *= -1
    else:
        if (t[1] == "1" and cou == 1)or(t[1] == "2" and cou == -1):
            frt = t[2] + frt
        else:
            bck = bck + t[2]
#    logging.debug("s {},cou {}".format(s,cou))

s = frt + s + bck
#logging.debug(s)#
if cou == 1:
    print(''.join(s))
else:
    print(''.join(s[::-1]))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
AB = [[] for i in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    AB[a].append(b)

X = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    X[p] += x


def dfs(p):
    for c in AB[p]:
        X[c] += X[p]
        dfs(c)


dfs(1)
print(" ".join(map(str, X[1:])))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)


N, Q = map(int, input().split())
AB = [[] for i in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    AB[a].append(b)

X = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    X[p] += x


def recursive(p):
    for c in AB[p]:
        X[c] += X[p]
        recursive(c)


recursive(1)
print(" ".join(map(str, X[1:])))
### BUGGY CODE ###

def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = [list(map(int, input().split())) for _ in range(M)]
    BC.sort(reverse=True, key=lambda x:x[1])
    cnt = 0
    for B,C in BC:
        A.extend([C for _ in range(B)])
        cnt += B
        if B >= N:
            break
    A.sort(reverse=True)
    ans = 0
    for i in range(N):
        ans += A[i]
    print(ans)

main()

### FIXED CODE ###

n,m=map(int,input().split())
ans=list(map(int,input().split()))
arr=[list(map(int,input().split())) for _ in range(m)]
arr=sorted(arr,reverse=True,key=lambda x:x[1])
tmp=0
for cnt,val in arr:
  ans+=[val]*cnt
  tmp+=cnt
  if tmp>=n:
    break
ans=sorted(ans,reverse=True)
print(sum(ans[:n]))
### BUGGY CODE ###

n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if s_x.index(i)<n//2:
        print(med_2)
    else:
        print(med_1)


### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if i<med_2:
        print(med_2)
    else:
        print(med_1)
### BUGGY CODE ###

def main():
    n, s = map(int, input().split())
    a = [int(i) for i in input().split()]
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        ai = a[i]
        for j in range(s + 1):
            if j < ai:
                dp[i + 1][j] = dp[i][j] * 2 % 998244353
            else:
                dp[i + 1][j] = (dp[i][j] * 2 + dp[i][j - ai]) % 998244353
    print(dp[n][s])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, s = map(int, input().split())
    a = sorted([int(i) for i in input().split()])
    mod = 998244353
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        ai = a[i]
        for j in range(s + 1):
            if j < ai:
                dp[i + 1][j] = dp[i][j] * 2 % mod
            else:
                dp[i + 1][j] = (dp[i][j] * 2 % mod + dp[i][j - ai]) % mod
    print(dp[n][s])

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

s=input()
line=[int(c) for c in s]
length=len(line)
while 1:
  for i in range(len(line)-1):
    if line[i]!=2 and line[i]!=line[i+1]:
      line[i]=2
      line[i+1]=2
  if 2 in line:
    line=[i for i in line if i!=2]
  else:
    break
print(length-len(line))

### FIXED CODE ###

s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('0')*2)
else:
    print(s.count('1')*2)
### BUGGY CODE ###


n=int(input())
s_=input()
r, g, b = s_.count("R"), s_.count("G"), s_.count("B")
rgb = r * g * b
cnt=0
for i in range(len(s_)):
  for j in range(i+1,len(s_)):
    h=j-i+j
    if h<=len(s_)-1:
      if s_[i]!=s_[j] and s_[h]!=s_[j] and s_[i]!=s_[h]:
        cnt+=1

print(rgb-cnt)

### FIXED CODE ###


n=int(input())
s_=input()
r, g, b = s_.count("R"), s_.count("G"), s_.count("B")
rgb = r * g * b
cnt=0
for i in range(len(s_)):
  for j in range(i+1,len(s_)):
    h=j-i+j
    if h<n:
      if s_[i]!=s_[j] and s_[h]!=s_[j] and s_[i]!=s_[h]:
        cnt+=1

print(rgb-cnt)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
S = input()

flg = [S[0]] #各連続部分の数字
count = []   #連続部分の個数
cnt = 1
tmp = S[0]

for x in S[1:]:
	if x == tmp:
		cnt += 1
	else:
		tmp = x
		flg.append(tmp)
		count.append(cnt)
		cnt = 1
count.append(cnt)

ans = 0
for i in range(len(flg)):
	if flg[i] == "1":
		ans = max(ans, sum(count[i:i+2*K+1]))
	else:
		ans = max(ans, sum(count[i:i+2*K]))

print(ans)



### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
#INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
S = [int(s) for s in input()] + [1]

r = -1
ans = 0
cnt = 0
used = [0]*(N+1)

for l in range(N):
	if S[l] + S[l-1] == 0:
		continue
	while r < N and used[r] - used[l-1] <= K:
		r += 1
		if S[r-1] == 1 and S[r] == 0:
			used[r] = used[r-1] + 1
		else:
			used[r] = used[r-1]
	ans = max(ans, r-l)

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

import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)
from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = [int(c) for c in input().split()]
    L = sorted(L)
    num = 0
    for ai in range(N):
        for bi in range(ai+1, N):
            if bi - ai == 1:
                continue
            a = L[ai]
            b = L[bi]
            ci_left = bisect_right(L[ai+1:bi], abs(L[ai] - L[bi]))
            ci_right = bisect_left(L[ai+1:bi], L[ai] + L[bi])
            # print(a, b, ci_left, min(ci_right, bi) - max(ci_left, ai) - 1)
            # num += min(ci_right, bi) - max(ci_left, ai) - 1
            num += ci_right - ci_left
            # print(a, b, ci_right, ci_left, num)

    print(num)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect

def main():
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    count = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            k = bisect.bisect_left(L, L[i] + L[j])
            k -= 1
            count += k - j
    print(count)


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

import sys
from pprint import pprint

def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

### FIXED CODE ###

import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)
### BUGGY CODE ###

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    zero = [0] * 61
    one = [0] * 61
    for i in range(n):
        for j in range(61):
            if a[i]>>j  & 1:
                one[j] += 1
            else:
                zero[j] += 1
    ans = 0
    for i in range(60):
        ans += ((one[i]*zero[i]) * pow(2, i, mod)) % mod
        ans %= mod
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    zero = [0] * 61
    one = [0] * 61
    for i in range(n):
        for j in range(61):
            if a[i]>>j  & 1:
                one[j] += 1
            else:
                zero[j] += 1
    ans = 0
    for i in range(60):
        ans += ((one[i]*zero[i]) * pow(2, i, mod)) % mod
        ans %= mod
    print(ans)
resolve()
### BUGGY CODE ###

n = int(input())

ans = 0
for x in range(1, n+1):
    y = int(n / x)
    ans += y * (y + 1) * x // 2

print(ans)

### FIXED CODE ###

n = int(input())

ans = 0
for x in range(1, n+1):
    y = int(n / x)
    ans += y * (y + 1) * x // 2

print(ans)