Almost Fibonacci


Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 977M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, C, C++, C11, CLANG, CLANGX, Classical, COBOL, Coffee, CSC, D lang, DART, F95, FORTH, Fortrn, GAS32, GO, Haskell, Itercal, Java, kotlin, LEAN, LISP, LUA, MONOVB, Nasm, OCAML, Pascal, Perl, php, PIKE, prolog, Pypy, Python, Ruby 2, RUST, Scala, SCM, SED, SWIFT, TCL, TUR, V8JS, VB, ZIG

A sequence (u) is defined as follows:

u0=0

u1=1

un=un1+un2+1 for all n2.

Given integer n, find the value of un modulo 109+7.

Input

A single integer n.

Note: Use 64bit integer to input number.

Output

A single integer.

Constraints

Subtask 1 (30%): 0n20.

Subtask 2 (30%): 0n106.

Subtask 3 (40%): 0n91018.

Example

Input:

Copy
4

Output:

Copy
7
QDUY

Comments

There are no comments at the moment.