jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let mut table: Vec<i64> = (0..=n).map(|i| i as i64).collect();
    'loop1: for i in 2..=n {
        if *table.get(i).expect("") < i as i64 {
            continue 'loop1;
        }
        for j in (i..=n).step_by(i) {
            table[j] = i as i64;
        }
    }
    let mut ans = 0;

    for mut i in 1_i64..=n as i64 {
        let mut cnt: HashMap<i64, usize> = HashMap::new();
        let mut ret = i as i64;
        while i != 1 {
            let prime = table[i as usize];
            *cnt.entry(prime).or_insert(0) += 1;
            i /= prime;
        }
        cnt.values().for_each(|val| {
            ret *= *val as i64 + 1;
        });
        ans += ret;
    }
    println!("{}", ans);
}
//  [rust]
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: i32 = 1000000007;

#[fastout]
fn main() {
  input!(n: usize);
  let mut v = vec![1 as i64; n + 1];
  for i in 2..=n {
    for j in (i..=n).step_by(i) {
      v[j] += 1;
    }
  }
  let mut ans = 0;
  for i in 1..=n {
    ans += v[i] * i as i64;
  }
  println!("{}", ans);
}
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let N = readInt()[0]
    var ans = 0
    for i in 1...N {
        let m = Int(floor(Double(N)/Double(i)))
        ans += (m * i * (m + 1)) / 2
    }
    print(ans)
}
main()
//  [swift]
func sum(n: Int) -> Int {
    n * (n+1) / 2
}

let N = Int(readLine()!)!

var ans = 0
for i in 1...N {
    ans += i * sum(n: N/i)
}
print(ans)
//  [swift]
let N = Int(readLine()!)!

var dp: [Int] = .init(repeating: 0, count: N + 1)

for i in 1...N {
  var current = i
  while current <= N {
    dp[current] += 1
    current += i
  }
}
var sum = 0 
for i in 1...N {
  sum += i * dp[i]
}
print(sum)
//  [swift]
func mainD() {
    let n = Int(readLine()!)!
    var ans = 0
    for i in 1...n {
        for j in stride(from: i, to: n+1, by: i) {
            ans += j
        }
    }
    print(ans)
}

mainD()
//  [typescript]
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split(" ");

const a = Number(input[0]);

let ans = 0;

for (let index = 1; index < a + 1; index++) {
  const divider = Math.floor(a / index);
  const result = (divider * (divider + 1) * index) / 2;
  ans += result;
}

console.log(ans);
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'

function divCnt(n : number) : number {
  let ans = 0
  for (let i = 1; i <= Math.sqrt(n); i++) {
    if (n % i == 0) {
      ans++
      if (i * i != n) {
        ans++
      }
    }
  }
  return ans
}

function main(input: string[]) {
  let N = Number(input[0])
  let ans = BigInt(0)

  // 1 : 1
  // 2 : 1 2
  // 3 : 1   3 
  // 4 : 1 2   4
  // 5 : 1        5
  // 6 : 1 2 3      6
  // 7 : 1            7
  // 8 : 1 2   4        8
  for (let i = 1; i <= N; i++) {
    let cnt = Math.floor(N / i)
    let ansOne = (cnt * (cnt + 1) / 2) * i
    ans += BigInt(ansOne)
  }

  console.log(ans.toString())
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});
//  [typescript]
import * as fs from "fs";
const n = parseInt(fs.readFileSync("/dev/stdin", "utf8"));
const counter = Array(n+1).fill(1);
for (let i = 2; i <= n; i++) {
    const base = i;
    let current = i;
    while (current <= n) {
        counter[current] += 1;
        current += base;
        //console.log(counter);
    }
}
let sum = 0;
for (let i = 1; i <= n; i++) {
    sum += i * counter[i];
}
console.log(sum);
//  [python]
MOD = 10**9 + 7
e, N = map(int, input().split())

def phi_table(N):
    phi = list(range(N + 1))
    for p in range(2, N + 1):
        if phi[p] == p:
            for n in range(N // p, 0, -1):
                phi[p * n] -= phi[n]
    return phi


L = int(N ** .66)
H = int(N // (L + 1))
phi = phi_table(L)

# f(n) = \sum_{i=1}^n phi(i)

f_l = phi.copy()
for n in range(L):
    f_l[n + 1] += f_l[n]

f_h = [0] * (H + 1)  # f(N//d)


def f(n):
    return f_l[n] if n <= L else f_h[N // n]


def compute_f(n):
    sq = int(n ** .5)
    x = n * (n + 1) // 2
    for d in range(1, n + 1):
        m = n // d
        if m <= sq:
            break
        x -= f(m)
    for m in range(1, sq + 1):
        cnt = n // m - n // (m + 1)
        x -= f_l[m] * cnt
    return x


for d in range(H, 0, -1):
    f_h[d] = compute_f(N // d)

sq = int(N ** .5)
answer = 0
for d in range(1, N + 1):
    n = N // d
    if n <= sq:
        break
    answer += pow(n, e, MOD) * phi[d]

for n in range(1, sq + 1):
    low_d = N // (n + 1)
    high_d = N // n
    phi_sum = f(high_d) - f(low_d)
    answer += phi_sum * pow(n, e, MOD)

answer %= MOD
print(answer)
//  [python]
N, K = map(int, input().split())
MOD = 10**9 + 7

M = int(K ** .5)
f_l = [0] * (M+1)  # f(k)
f_h = [0] * (M+1)  # f(K//d)

def f(k):
  return f_l[k] if k <= M else f_h[K//k]

def compute_f(k):
  x = pow(k, N, MOD)
  sq = int(k ** .5)
  for d in range(2, k+1):
    n = k // d
    if n <= sq:
      break
    x -= f(n)
  for n in range(1, sq+1):
    cnt = k//n - k//(n+1)
    x -= f_l[n] * cnt
  return x

for k in range(1, M+1):
  f_l[k] = compute_f(k)

for d in range(M, 0, -1):
  f_h[d] = compute_f(K//d)

answer = 0

for k in range(1, M+1):
  low_d = K // (k+1) + 1
  high_d = K // k
  items = high_d - low_d + 1
  coef = (low_d + high_d) * items // 2
  answer += coef * f_l[k]
  
for d in range(1, M+1):
  if K // d <= M:
    break
  answer += d * f_h[d]

answer %= MOD
print(answer)
//  [python]
n, k = map(int,input().split())
mod = 10**9 + 7

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

A = [0] + [k//i for i in range(1, k+1)]
B = list(set(A))
# print("A",A)
D = {}
for i in B:
    D[i] = pow(i, n, mod)

# print(D)

ans = [0] * (k+1)
for i in range(k, 0, -1):
    ans[i] = D[A[i]] % mod
    # print("ans",i,ans[i])
    ii = i * 2
    while ii <= k:
        # print("ii",ii,D[ii])
        ans[i] = (ans[i] - ans[ii]) % mod
        ii += i
# print(ans)
# print(sum(ans) % mod)

anss = 0
for i in range(1, len(ans)):
    anss = (anss + ans[i] * i) % mod
print(anss)
//  [python]
n,k=map(int,input().split())
mod=10**9+7
ans=0
d=[0]*(k+1)
for i in range(k,0,-1):
	c=k//i
	t=pow(c,n,mod)
	t+=(d[i]//mod+1)*mod-d[i]
	t%=mod
	ans+=t*i
	ans%=mod
	for j in range(1,int(i**.5)+1):
		if i%j==0:
			d[j]+=t
			if j!=i//j:
				d[i//j]+=t
print(ans)
//  [python]
from functools import lru_cache


mod = 10 ** 9 + 7
N, K = map(int, input().split())

@lru_cache
def gcd1_tuples(k):
    if k == 1:
        return 1
    tmp = pow(k, N, mod)
    for j in range(2, k+1):
        tmp -= gcd1_tuples(k//j)
        tmp %= mod
    return tmp

s = 0
for i in range(1, K+1):
    s += gcd1_tuples(K//i) * i
    s %= mod

print(s)
//  [python]
import numpy as np
N,K = map(int,input().split())
res = np.zeros(K+1, dtype=np.int64)
ans = 0
MOD = 10**9+7
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return np.array(divisors, dtype=np.int64)

for k in range(K,0,-1):
    y = make_divisors(k)
    s = K//k
    tmp = pow(s, N, MOD)
    ans += k*(tmp-res[k])
    # print(res[k], tmp, ans)
    res[y] += tmp-res[k]
print(ans%MOD)
//  [java]
import java.util.*;
import java.lang.*;
class Mod{
    static final int MOD = 1000_000_007;
    static final int[] fact, factInv;
  	static {
      int size = 80_000_000;
      fact = new int[size];
      fact[0]=1;
      for(int i=1;i<fact.length;i++){
        fact[i]=mult(fact[i-1],i);
      }
      factInv = new int[size];
      factInv[size - 1] = inverse(fact[size - 1]);
      for (int i = size - 2;i >= 0;-- i) {
        factInv[i] = mult(factInv[i + 1], i + 1);
      }
    }

    public static int add(int a, int b){
        int tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static int adds(int... ar){
        int ans=0;
        for(int x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static int sub(int a, int b){
        return add(a,-b);
    }
    public static int mult(int a, int b){
        int tmp = (int)((long)a*b%MOD);
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static int mults(int... ar){
        int ans=1;
        for(int x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static int power(int a, int x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            int half = power(a,x/2);
            return mult(half,half);
        }
        return (int)((long)a*power(a,x-1) % MOD);
    }
    public static int inverse(int a){
        return power(a,MOD-2);
    }
    public static int div(int a, int b){
        return mult(a, inverse(b));
    }
  	
    public static int combination(int n, int r){
        int N = n,  R = r;
        if(n<0 || r<0 || n<r) return 0;
        return mults(fact[N],factInv[R],factInv[N-R]);
    }
    public static int permutation(int n, int r){
        int N = n,  R = r;
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[N], factInv[N-R]);
    }
}

public class Main {
    static int count(int N, int K, int M){
        return Mod.power(K/M, N);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long startTime = System.currentTimeMillis();
        int[] ans = new int[K+1];
        for(int k=K; k>0; k--){
            ans[k] = count(N, K, k);
            for(int i=2; i*k<=K; i++) ans[k] = Mod.sub(ans[k], ans[i*k]);
        }

        int total = 0;
        for(int k=1; k<=K; k++) total = Mod.add(total, Mod.mult(k, ans[k]));
        System.err.printf("%.3f sec\n", (System.currentTimeMillis()-startTime)*0.001);
        System.out.println(total);
    }
}
//  [java]
import java.util.*;

public class Main {

    static long mod = 1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        memo = new int[k+1];

        long res = 0;
        long[] num = new long[k+1];
        for(int i=k; i>=1; i--) {
            long a = b(k / i, n);
            for(int b = 2; i * b <= k; b++) {
                a += mod - num[i * b];
                a %= mod;
            }
            num[i] = a;
            res += num[i] * i;
            res %= mod;
        }

        System.out.println(res);
    }

    static int[] memo;

    static int b(int a, int b) {
        if(memo[a] > 0) return memo[a];
        long res = 1;
        for(int i=0; i<b; i++) {
            res *= a;
            res %= mod;
        }
        return memo[a] = (int)res;
    }


}
//  [cpp]
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto r{1UL}, n{N}, a{t};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        ans += (r + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - r;
    }
    cout << ans % MOD << endl;
    return 0;
}
//  [cpp]
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto k = modpow(t, N);
        ans += (k + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - k;
    }
    cout << ans % MOD << endl;
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
#define MOD 1000000007
ll dp[100005];
ll RS(ll x,ll y,ll mod){
    if(y==0) return 1;
    else if(y&1) return x*RS(x,y-1,mod)%mod;
    else {
        ll p= RS(x,y/2,mod);
        return p*p%mod;
    }
}
int main(){
    ll n,k;
    cin >> n >> k;
    dp[1]=1;
    dp[2]=RS(2,n,MOD)-1;
    for(ll i=3; i<=k; i++){
        dp[i]=RS(i,n,MOD);
        for(ll j=2; j<=sqrt(i); j++){
            dp[i]-=dp[i/j];
            while(dp[i]<0) dp[i]+=MOD;
        }
        for(ll j=1;j<=i/((int)sqrt(i)/1+1);j++){
            dp[i]-=dp[j]*(i/j-i/(j+1));
            while(dp[i]<0) dp[i]+=MOD;
        }
    }
    ll ans=0;
    for(ll i=1; i<=k; i++){
        ans+=dp[k/i]*i;
        ans%=MOD;
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

long long MOD = 1000000007;
long long numseq[100005];

long long n, k;

long long modpow(long long x, long long e) {
    if (e == 0) return 1;
    if (e == 1) return x;
    if (e % 2 == 0) {
        long long half = modpow(x, e / 2);
        return (half * half) % MOD;
    } else {
        return (modpow(x, e - 1) * x) % MOD;
    }
}

long long calc(int x) {
    if (numseq[x] > 0) return numseq[x];
    long long ans = 0;
    long long num_div = k / x;
    ans = modpow(num_div, n);
    for (int i = x * 2; i <= k; i += x) {
        ans -= calc(i);
    }
    return numseq[x] = ans;
}

int main() {
    cin >> n >> k;

    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        ans = (ans + calc(i) * i) % MOD;
    }
    cout << ans << endl;
    return 0;
}
//  [c]
#include<stdio.h>

int main(){
    unsigned long N, K, ans = 0, v[100001];
    scanf("%lu%lu", &N, &K);
    for(unsigned long i = 1; i <= K; ++i)v[i] = i;
    for(unsigned long i = 2; i <= K; ++i)if(v[i] == i)for(unsigned long j = i; j <= K; j += i)v[j] = (v[j] / i) * (i - 1);
    for(unsigned long i = 1; i <= K; ++i)v[i] = (v[i] + v[i - 1]) % 1000000007;
    for(unsigned long i = K, p = 0; i; ){
        unsigned long t = K / i, r = 1, n = N, a = t;
        while(n){
            if(n & 1){
                r *= a;
                r %= 1000000007;
            }
            a *= a;
            a %= 1000000007;
            n >>= 1;
        }
        ans += (r + p) * v[i];
        i = K / (t + 1);
        p = 1000000007 - r;
    }
    printf("%lu\n", ans % 1000000007);
    return 0;
}
//  [c]
#pragma GCC optimize("Ofast")
#include<stdio.h>

int main(){
    unsigned long N, K, ans = 0, v[100001];
    scanf("%lu%lu", &N, &K);
    for(unsigned long i = 1; i <= K; ++i)v[i] = i;
    for(unsigned long i = 2; i <= K; ++i)if(v[i] == i)for(unsigned long j = i; j <= K; j += i)v[j] = (v[j] / i) * (i - 1);
    for(unsigned long i = 1; i <= K; ++i)v[i] = (v[i] + v[i - 1]) % 1000000007;
    for(unsigned long i = K, p = 0; i; ){
        unsigned long t = K / i, r = 1, n = N, a = t;
        while(n){
            if(n & 1){
                r *= a;
                r %= 1000000007;
            }
            a *= a;
            a %= 1000000007;
            n >>= 1;
        }
        ans += (r + p) * v[i];
        i = K / (t + 1);
        p = 1000000007 - r;
    }
    printf("%lu\n", ans % 1000000007);
    return 0;
}
//  [c]
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define MOD 1000000007

long powlong(long a, int b) {
  long res = 1;
  if (a == 1)
    return 1;
  for (; b>0; b>>=1, a=(a*a)%MOD) {
    if (b%2) {
      res *= a;
      res %= MOD;
    }
  }
  return res;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long a[k], ans = 0;
  for (int i=k-1; i>=0; i--) {
    a[i] = powlong(k/(i+1), n);
    for (int j=2*i+1; j<k; j+=i+1) {
      a[i] -= a[j];
      a[i] %= MOD;
    }
  }
  for (int i=0; i<k; i++) {
    ans += ((i+1)*a[i])%MOD;
    ans %= MOD;
  }
  printf("%ld\n", ans);
  return 0;
}
//  [c]
#include <stdio.h>
long long p = 1000000007;
long long rui(long long rui_a, long long rui_b) {
	if (rui_b == 0)return 1;
	if (rui_b == 1)return rui_a % p;
	long long rui_c;
	rui_c = rui(rui_a, rui_b / 2);
	rui_c = rui_c * rui_c % p;
	if (rui_b % 2) {
		return rui_c * rui_a % p;
	}
	return rui_c;
}
long long n, k, x, y, z;
long long m[100001];
long long ans[100001];
int main() {
	scanf("%lld%lld", &n, &k);
	m[1] = 1;
	for (long long i = 2; i <= k; i++) {
		z = 0;
		for (long long j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				if ((i / j) % j == 0)m[i] = 0;
				else m[i] = -m[i / j];
				z = 1;
				break;
			}
		}
		if (z == 0)m[i] = -1;
	}
	z = 0;
	for (long long i = 1; i <= k; i++) {
		x = k / i;
		x = rui(x, n);
		y = 1;
		while (y * y < i) {
			if (i % y == 0) {
				ans[y] += x * m[i / y];
				ans[y] += p;
				ans[y] %= p;
				ans[i / y] += x * m[y];
				ans[i / y] += p;
				ans[i / y] %= p;

			}
			y++;
		}
		if (y * y == i) {
			ans[y] += x * m[y];
			ans[y] += p;
			ans[y] %= p;
		}
	}
	for (int i = 1; i <= k; i++) {
		z += ans[i] * i;
		z %= p;
	}
	printf("%lld\n", z);
}
//  [c]
#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int p = 1000000007;
	long long int cnt[100005];
	long long int i, j;
	for (i = 1; i <= k; i++)
		cnt[i] = modpow(k / i, n, p);
	for (i = k; i > 1; i--)
	{
		cnt[1] = (cnt[1] - cnt[i] + p) % p;
		for (j = 2; j * j <= i; j++)
		{
			if (i % j == 0)
			{
				cnt[j] = (cnt[j] - cnt[i] + p) % p;
				if (j * j < i)
					cnt[i / j] = (cnt[i / j] - cnt[i] + p) % p;
			}
		}
	}
	long long int ans = 0;
	for (i = 1; i <= k; i++)
		ans = (ans + i * cnt[i] % p) % p;
	printf("%lld\n", ans);
	return 0;
}
//  [javascript]
function Main(input) {
    var sum  = function(arr) {
        var sum = 0;
        arr.forEach(function(elm) {
            sum += elm;
        });
        return sum;
    };
    var C = 1e+9 + 7;
    var C2 = 1e+5;
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0][0], 10);
    var K = parseInt(input[0][1], 10);

    var vec_ruijoR = Array.from({length: Math.ceil(K)}, () => 0);
    var tmp;
    for (var i = 1; i <= K; i++){
        tmp = (K / i | 0);
        i = (K / tmp | 0);
        vec_ruijoR[i -1] = oldProduct = fastRuijoR(i, N, C, C2);
    }
    var vec_countPattern = Array.from({length: K}, () => 0);
    var limit;
    var ans = 0;
    for (var x = K; x >= 1; x --){
        limit = (K / x | 0);
        tmp = vec_ruijoR[limit - 1];
        for (var j = 2; j <= limit; j ++){
            tmp -= vec_countPattern[x * j - 1];
        }
        tmp = mod(tmp, C);
        ans += kakeruR(x, tmp, C, C2);
        // console.log("xa", x, ans);
        ans %= C;
        vec_countPattern[x - 1] = tmp;
    }
    console.log(ans);
}

function kakeruR(a, b, C, C2){
    var tmpQ, tmpR, ans;
    tmpQ =  (b / C2 | 0);
    tmpR =  b - (tmpQ * C2);
    ans = (a * tmpQ % C) * C2 % C + (a * tmpR);
    ans %= C;
    return ans;
}

function fastRuijoR(a, b, C, C2){
    var ans = 1;
    var binary = b.toString(2);
    var l = binary.length;
    var tmp = a;
    for (var i = 0; i < l; i++){
        if (binary.substr((i + 1) * -1, 1) == '1') ans = kakeruR(ans, tmp, C, C2);
    tmp = kakeruR(tmp, tmp, C, C2);
    }
    return ans;
}

function mod(i, j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var k = next();
  var s = xArray(0,k+1);
  var ans = k;
  s[k] = 1;
  for(var i = k-1; i > 0; i--){
    s[i] = pow(k/i|0, n);
    for(var j = i+i; j <= k; j += i){
      s[i] -= s[j];
    }
    s[i] %= mod;
    if(s[i] < 0)s[i] += mod;
    ans += mul(s[i], i);
 }
  return ans % mod;
}
//  [go]
package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	const m int = 1e9 + 7
	pow := func(x, n int) int {
		res := 1
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % m
			}
			x = x * x % m
		}
		return res
	}
	var n, k, s int
	Scan(&n, &k)
	ans := make([]int, k+1)
	for i := k; i > 0; i-- {
		v := pow(k/i, n)
		for j := 2 * i; j <= k; j += i {
			v -= ans[j]
		}
		ans[i] = v % m
		s += i * ans[i]
	}
	Print((s%m + m) % m)
}
//  [go]
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	dp := [100010]int64{}
	for i := K; i > 0; i-- {
		dp[i] = ModPow(int64(K/i), int64(N))
		for j := 2; i*j <= K; j++ {
			dp[i] -= dp[j*i]
		}
	}
	sum := int64(0)
	for i := 1; i <= K; i++ {
		sum = ModAdd(sum, ModMul(int64(i), dp[i]))
	}
	fmt.Println(sum)

}
//  [go]
package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	const m int = 1e9 + 7
	pow := func(x, n int) int {
		res := 1
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % m
			}
			x = x * x % m
		}
		return res
	}
	var n, k, s int
	Fscan(_r, &n, &k)
	ans := make([]int, k+1)
	for i := k; i > 0; i-- {
		v := pow(k/i, n)
		for j := 2 * i; j <= k; j += i {
			v -= ans[j]
		}
		ans[i] = v % m
		s += i * ans[i]
	}
	Fprint(_w, (s%m+m)%m)
}

func main() { run(os.Stdin, os.Stdout) }
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dp := make([]int64, k+1)
	for i := 1; i <= k; i++ {
		dp[i] = mod(pow(int64(i), n))
	}
	for i := 2; i <= k; i++ {
		prev := i
		d := 1
		for prev > 1 {
			j := i / (d + 1)
			dp[i] = mod(dp[i] - mod(dp[d]*int64(prev-j)))
			d = i / j
			prev = j
		}
	}

	var ans int64
	for i := 1; i <= k; i++ {
		ans = mod(ans + mod(dp[k/i]*int64(i)))
	}
	fmt.Fprintln(writer, ans)
}

func pow(k int64, n int) int64 {
	m := int64(1e9 + 7)
	d := make([]int64, 63)
	d[0] = k
	for i := 0; i < 62; i++ {
		d[i+1] = d[i] * d[i] % m
	}
	var a int64
	a = 1
	for i := 62; i >= 0; i-- {
		if n>>uint(i)%2 == 0 {
			continue
		}
		a = mod(a * d[i])
	}

	return a
}

func mod(a int64) int64 {
	m := int64(1e9 + 7)
	return (a%m + m) % m
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt64(scanner)
	k := getNextInt64(scanner)

	var ans int64

	ccc := make([]int64, k+1)
	for i := int64(2); i <= k; i++ {
		ccc[i] = pow(k/i, n)
	}

	for i := k; i > 2; i-- {
		x := i
		dd := div(x)
		for di := len(dd) - 1; di >= 0; di-- {
			if di < len(dd)-1 && dd[di] == dd[di+1] {
				continue
			}
			ccc[dd[di]] = mod(ccc[dd[di]] - ccc[i])
		}
	}
	ccc[1] = pow(k, n)
	for i := k; i >= 2; i-- {
		ccc[1] = mod(ccc[1] - ccc[i])
	}
	for i := k; i >= 1; i-- {
		ans = mod(ans + mod(ccc[i]*i))
	}

	fmt.Fprintln(writer, ans)
}

func pow(k, n int64) int64 {
	doubling := make([]int64, 63)
	doubling[0] = k
	for i := 1; i < 63; i++ {
		doubling[i] = mod(doubling[i-1] * doubling[i-1])
	}
	var ans int64
	ans = 1
	for i := 63 - 1; i >= 0; i-- {
		if n>>uint(i)%2 == 1 {
			ans = mod(ans * doubling[i])
		}
	}
	return ans
}

func mod(x int64) int64 {
	m := int64(1e9 + 7)

	return (x%m + m) % m
}

func div(x int64) i64 {
	dd := make(i64, 0)
	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			dd = append(dd, i)
			if i*i < x {
				dd = append(dd, x/i)
			}
		}
	}

	sort.Sort(dd)
	return dd
}

type i64 []int64

func (a i64) Len() int           { return len(a) }
func (a i64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a i64) Less(i, j int) bool { return a[i] < a[j] }
//  [ruby]
mod = 10 ** 9 + 7

n, k = gets.split.map(&:to_i)

a = [1] * (k+1)
# b = Array.new(k+1){|i| i }

ans = 0
(k/2).downto(1) do |i|
  cnt = ( k/i ).pow( n, mod )
  
  j = i * 2
  while j <= k
    cnt = ( cnt - a[j] ) % mod
    j += i
  end
  
  a[i] = cnt
  ans += i * cnt % mod
  # ans %= mod if ans >= mod
end

puts (ans + (k-k/2) * ( k + k/2+1) / 2 ) % mod
//  [ruby]
n, k = gets.split.map(&:to_i)
mod = 10 ** 9 + 7

a = Array.new(k+1, 1)
b = [*0..k]

(k/2).downto(1) do |i| 
 cnt = (k/i).pow(n, mod)

 j = i*2
 while j <= k
  cnt = ( cnt - a[j] ) % mod
  j += i
 end

 a[i] = cnt
 b[i] = i * cnt % mod
end

puts b.inject(0, :+) % mod
//  [ruby]
mod = 10 ** 9 + 7

n, k = gets.split.map(&:to_i)

a = [1] * (k+1)
# b = Array.new(k+1){|i| i }

ans = 0
(k/2).downto(1) do |i|
  cnt = ( k/i ).pow( n, mod )
  (i*2).step(k, i){|j| cnt = ( cnt - a[j] ) % mod }
  a[i] = cnt
  ans += i * cnt % mod
  # ans %= mod if ans >= mod
end

puts (ans + (k-k/2) * ( k + k/2+1) / 2 ) % mod
//  [ruby]
eval"N,K="+`tr ' ' ,`
p K.downto(1).sum{|i|i*$*[i]=-(2..t=K/i).sum{$*[i*_1]}+t.pow(N,M=10**9+7)}%M
//  [ruby]
eval"N,K="+`tr \\  ,`
p K.downto(1).map{|k|t=(K/k).pow N,M=10**9+7
k.step(K,k){|j|t-=$*[j]||0}
k*$*[k]=t}.sum%M
//  [ruby]
eval"N,K="+`tr ' ' ,`
p (-10**5...0).sum{|i|i*$*[-i]=-(2..t=K/-i).sum{$*[-i*_1]}-t.pow(N,M=10**9+7)}%M
//  [rust]
use std::io::*;
const MOD: usize = 1_000_000_007;

fn pow(mut x: usize, mut e: usize) -> usize {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut table: Vec<usize> = vec![0; 100010];
    let mut prime = vec![true; 100010];
    for i in 1..k + 1 {
        table[i] = pow(k / i, n);
    }

    for i in 2..k + 1 {
        if prime[i] {
            for j in 1..k / i + 1 {
                prime[i * j] = false;
                table[j] = (table[j] + MOD - table[i * j]) % MOD;
            }
        }
    }

    let mut ans = 0;
    for i in 1..k + 1 {
        ans = (ans + table[i] * i % MOD) % MOD;
    }
    println!("{}", ans);
}
//  [rust]
// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 {0} else {MOD - self.0})
    }
}

impl std::fmt::Display for ModInt {
    fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl std::str::FromStr for ModInt {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let val = s.parse::<u32>()?;
        Ok(ModInt::new(val))
    }
}

impl From<usize> for ModInt {
    fn from(val: usize) -> ModInt {
        ModInt((val % MOD as usize) as u32)
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        assert!(self.0 > 0);
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------

use proconio::*;

fn run() {
    input! {
        n: u32,
        k: usize,
    }
    let mut memo = vec![ModInt::zero(); k + 1];
    for i in (1..=k).rev() {
        let mut way = ModInt::from(k / i).pow(n);
        let mut j = 2 * i;
        while let Some(&v) = memo.get(j) {
            way -= v;
            j += i;
        }
        memo[i] = way;
    }
    let mut ans = ModInt::zero();
    for (i, c) in memo.into_iter().enumerate() {
        ans += ModInt::from(i) * c;
    }
    println!("{}", ans);
}

fn main() {
    run();
}
//  [rust]
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

#[allow(dead_code)]
fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

const MOD :u64 = 1_000_000_007;

#[allow(dead_code)]
fn pow(mut x: u64, mut y: u64) -> u64 {
    let mut r = 1;
    while y > 0{
        if (y&1) == 1{
            r = r*x%MOD;
        }
        y >>= 1;
        x = x*x%MOD;
    }
    r
}


fn main(){
    let mut scan = Scanner::new();
    let n:usize = scan.next();
    let k:usize = scan.next();
    let mut v:Vec<u64> = vec![0; k + 1];

    for i in (1..k+1).rev(){
        let m:u64 = (k / i) as u64; 
        v[i] = pow(m, n as u64);

        let mut j = 2;
        while i*j <= k {
            if v[i] >= v[i*j]{
                v[i] -= v[i*j];
            }else{
                v[i] = MOD - v[i*j] + v[i];
            }
            j += 1;
        }
    }
    let mut ans = 0;
    for i in 1..k+1{
        ans += v[i] * i as u64;
        ans %= MOD;
    }
    println!("{}", ans);
}
//  [swift]
let nk = readLine()!.split(separator: " ")
let n = Int(nk[0])!
let k = Int(nk[1])!
let mod = 1000000007

func pow(_ a: Int, _ n: Int, _ mod: Int? = nil) -> Int {
    var a = a
    var n = n
    var result: Int = 1
    if let unwrappedMod = mod {
        while n > 0 {
            if n & 1 == 1 {
                result = result * a % unwrappedMod
            }
            n >>= 1
            a = a * a % unwrappedMod
        }
        return result
    }
    else {
        while n > 0 {
            if n & 1 == 1 {result *= a}
            n >>= 1
            a *= a
        }
        return result
    }
}

var table = [Int: Int]()

for i in (1...k).reversed() {
    var tmp = pow((k / i), n, mod)
    for j in 2...k {
        if let unwrappedVal = table[j * i] {
            tmp -= unwrappedVal
        }
        else {break}
    }
    table[i] = tmp % mod
}

var result = 0
for (key, value) in table {
    result += key * value
    result %= mod
}
if result < 0 {
    result += mod
}

print(result)
//  [swift]
import Foundation

let string = readLine()!.split(separator: " ")
let N = Int(string[0])!
let K = Int(string[1])!

func pow(_ x: Int, _ y: Int) -> Int {
    NSDecimalNumber(decimal: pow(Decimal(x), y)).intValue
}
func powmod(_ base: Int, _ exponent: Int, _ mod: Int = 1_000_000_007) -> Int {
    guard exponent != 0 else { return 1 }

    var temporary = 1
    var b = base
    var p = exponent

    while p > 1 {
        if p % 2 == 1 {
            temporary = temporary * b % mod
            p -= 1
        }
        if p != 0 {
            b = b * b % mod
            p /= 2
        }
    }

    return temporary * b % mod
}

let mod = pow(10, 9) + 7

var memory = Array(repeating: 0, count: K + 1)
for i in (1 ... K).reversed() {
    var result: Int = powmod(K / i, N) % mod

    guard K / i >= 2 else {
        memory[i] = result
        continue
    }
    for j in 2 ... K / i {
        result -= memory[j * i]
    }
    memory[i] = result
}

var sum = 0
for i in 1 ... K {
    sum += (memory[i] * i % mod)
    sum %= mod
}

print(sum)
//  [typescript]
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(a: number, b: number) {
  let arr = [];
  for (let i = a; i < b; i++) arr.push(i);
  return arr;
}
function gcd(a: number, b: number) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
const mod = 1000000007n;
function pow(base: bigint, a: bigint): bigint {
  if (a === 0n) return 1n;
  const half = pow(base, a / 2n);
  return (((half * half) % mod) * (a % 2n === 0n ? 1n : base)) % mod;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const [N, K] = ints(2);
  const ans: bigint[] = [];
  function dp(a: number) {
    if (ans[a]) return ans[a];
    else {
      const s: bigint = BigInt(K) / BigInt(a);
      const total = pow(s, BigInt(N));
      let minus = 0n;
      for (let i = 2; i <= s; i++) {
        minus = (minus + dp(BigInt(i) * BigInt(a))) % mod;
      }
      return (ans[a] = (total - minus + mod) % mod);
    }
  }
  dp(1);

  let sum = 0n;
  for (let i = 1; i <= K; i++) {
    sum = (sum + ans[i] * BigInt(i)) % mod;
  }
  console.log(sum.toString());
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [python]
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache, reduce

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# S = sys.stdin.readline().rstrip()
# c = list(S)
# if c[0] == c[1] or c[1] == c[2] or c[2] == c[3]:
#     print('Bad')
# else:
#     print('Good')

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

a = np.arange(L, L + N)
d = abs(a).argmin()
print(a.sum() - a[d])
//  [python]
import numpy as np

N, L = map(int, input().split())

tastes = np.arange(N) + L
idx = np.argmin(np.abs(tastes))
tastes[idx] = 0
print(np.sum(tastes))
//  [python]
n, l = map(int, input().split())
t = [l + i for i in range(n)]
abs_t = list(map(abs, t))
ans = sum(t) - t[abs_t.index(min(abs_t))]
print(ans)
//  [java]

import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer l = Integer.parseInt(scanner.next());


        Integer[] taste = new Integer[n];
        for(int i = 1; i <= n; i++) {
            taste[i-1] = l + i - 1;
        }


        int max = Math.abs(taste[0]);
        int min = Math.abs(taste[1]);
        for(int i = 0; i < taste.length; i++) {
            int v = Math.abs(taste[i]);
            if (v > max) {
                max = v;
            }
            if (v < min) {
                min = v;
            }
        }

        int sum = Stream.of(taste).mapToInt(Integer::intValue).sum();

        if( sum < 0) {
            System.out.println(sum + min);
        } else {
            System.out.println(sum - min);
        }

    }
}
//  [java]
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),l=s.nextInt();
		int[]a=IntStream.range(l,l+n).toArray();
		//System.err.println(Arrays.toString(a));

		int sum=Arrays.stream(a).sum();
		int min=Arrays.stream(a).boxed().min(Comparator.comparingInt(Math::abs)).get();
		System.err.println(sum);
		System.err.println(min);
		System.out.println(sum-min);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            Integer N = Integer.valueOf(args.get(0).split(" ")[0]);
            Integer L = Integer.valueOf(args.get(0).split(" ")[1]);
            Integer sum = IntStream.range(0, N).map(n -> n + L).sum();
            int min = Integer.MAX_VALUE;
            boolean minus = true;
            for (int i = 0; i < N; i++) {
                if (min > Math.abs(i + L)) {
                    min = Math.abs(i + L);
                    minus = i + L < 0;
                }
            }
            System.out.println(sum - ((minus) ? -min : min));
        };
    }

}
//  [cpp]
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a>>b;
  c=(a-1)*a/2;
  c+=a*b;  
  if(a+b<=0)cout<<c-b-a+1;
  else if(b>0)cout<<c-b;
  else cout<<c;
}
//  [cpp]
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n, l;
	cin >> n >> l;
	int d[200];
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		d[i] = l + i;
		sum += d[i];
	}

	int check = sum;
	check -= d[0];
	int near = check;
	for (int i = 1; i < n; i++)
	{
		check += d[i - 1];
		check -= d[i];
		if (abs(check - sum) < abs(near - sum))
		{
			near = check;
		}
	}
	cout << near;
}