AtCoder Regular Contest 071
F
Infinite Sequence
AtCoder
⌀ 2336
原题
← E→
翻译中…

Problem Statement

翻译中…

How many infinite sequences $a_1, a_2, ...$ consisting of {${1, ... ,n}$} satisfy the following conditions?

翻译中…
  • The $n$-th and subsequent elements are all equal. That is, if $n \leq i,j$, $a_i = a_j$.
  • For every integer $i$, the $a_i$ elements immediately following the $i$-th element are all equal. That is, if $i < j < k\leq i+a_i$, $a_j = a_k$.
翻译中…

Find the count modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1 \leq n \leq 10^6$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

n

翻译中…

Output

翻译中…

Print how many sequences satisfy the conditions, modulo $10^9+7$.

翻译中…

样例

Input #1
2
Output #1
4
The four sequences that satisfy the conditions are: - $1, 1, 1, ...$ - $1, 2, 2, ...$ - $2, 1, 1, ...$ - $2, 2, 2, ...$
Input #2
654321
Output #2
968545283
题目信息
题号
arc071_d
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。