PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000057. Tổng có trọng số trên đoạn nguyên tố (Weighted Sum of Primes in an Interval)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng có trọng số trên đoạn nguyên tố (Weighted Sum of Primes in an Interval)

Weighted Sum of Primes in an Interval

Source: LQDOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers l≤rl\le r, list all primes in the inclusive range [l,r][l,r] in increasing order p1<p2<⋯<pkp_1<p_2<\cdots<p_k. The first prime has weight 11, the second weight 22, and prime pjp_j has weight jj. Compute p1+2p2+⋯+kpkp_1+2p_2+\cdots+kp_k modulo 109+710^9+7. If the interval contains no primes, the sum is 00.

Input

One line contains two positive integers ll and rr.

Output

Print one integer in [0,109+6][0,10^9+6]: the weighted sum reduced modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤l≤r≤9991\le l\le r\le 999.
  • Subtask 2 (20 points): 1≤l≤r≤999991\le l\le r\le 99999.
  • Subtask 3 (60 points): 1≤l≤r≤9999991\le l\le r\le 999999.

Examples

Input

3 7

Output

34

Explanation

The primes in [3,7][3,7] are 3,5,73,5,7. Their weights are 1,2,31,2,3, so the terms are 1⋅3=31\cdot3=3, 2⋅5=102\cdot5=10, and 3⋅7=213\cdot7=21. The sum 3+10+21=343+10+21=34 is less than 109+710^9+7; print 34.