One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.

The maze is organized as follows. Each room of the maze has two one-way portals. Let's consider room number i (1 ≤ i ≤ n), someone can use the first portal to move from it to room number (i + 1), also someone can use the second portal to move from it to room number pi, where 1 ≤ pi ≤ i.

In order not to get lost, Vasya decided to act as follows. 

  * Each time Vasya enters some room, he paints a cross on its ceiling. Initially, Vasya paints a cross at the ceiling of room 1. 
  * Let's assume that Vasya is in room i and has already painted a cross on its ceiling. Then, if the ceiling now contains an odd number of crosses, Vasya uses the second portal (it leads to room pi), otherwise Vasya uses the first portal. 



Help Vasya determine the number of times he needs to use portals to get to room (n + 1) in the end.

Input

The first line contains integer n (1 ≤ n ≤ 103) — the number of rooms. The second line contains n integers pi (1 ≤ pi ≤ i). Each pi denotes the number of the room, that someone can reach, if he will use the second portal in the i-th room.

Output

Print a single number — the number of portal moves the boy needs to go out of the maze. As the number can be rather large, print it modulo 1000000007 (109 + 7).

Examples

Input

2
1 2


Output

4


Input

4
1 1 2 3


Output

20


Input

5
1 1 1 1 1


Output

62


import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Scanner;

public class P1 {

	public static void main(String[] args) {
		FastScanner scanner = new FastScanner();
		OutputWriter out = new OutputWriter(System.out);
		int n = scanner.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt() - 1;
		}
		int[] dp = new int[n];
		dp[0] = 1;
		for (int i = 1; i < n; i++) {
			dp[i] = i - a[i] + 1;
			for (int j = a[i]; j < i; j++) {
				dp[i] += dp[j];
				dp[i] %= 1000000007;

			}
			//System.out.println("dp[" + i + "] = " + dp[i]);
		}
		int[] arriveTime = new int[n + 1];
		arriveTime[0] = 0;
		for (int i = 1; i < n + 1; i++) {
			arriveTime[i] = arriveTime[i - 1] + dp[i - 1] + 1;
			arriveTime[i] %= 1000000007;
		}
		System.out.println(arriveTime[n]);

	}
}

class FastScanner {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public FastScanner() {
		this.stream = System.in;
	}

	public FastScanner(InputStream stream) {
		this.stream = stream;
	}

	public FastScanner(String fileName) {
		try {
			this.stream = new FileInputStream(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public int nextInt() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextChar();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = nextChar();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public int nextChar() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public double nextDouble() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextChar();
		}
		double res = 0;
		long dotPlace = 1;
		boolean hasReachedDot = false;
		do {
			if (c != '.' && (c < '0' || c > '9'))
				throw new InputMismatchException();
			if (c == '.') {
				hasReachedDot = true;
				c = nextChar();
				continue;
			}
			if (hasReachedDot)
				dotPlace *= 10;
			res *= 10;
			res += c - '0';
			c = nextChar();
		} while (!isSpaceChar(c));
		return res * sgn / dotPlace;

	}

	public long nextLong() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextChar();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = nextChar();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = nextChar();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}
}

class OutputWriter {
	private PrintWriter writer;

	public OutputWriter() {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(String fileName) {
		try {
			writer = new PrintWriter(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public void print(Object s) {
		writer.print(s);
	}

	public void println(Object s) {
		writer.println(s);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}