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.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.InputMismatchException;
 
public class LongPath {
	static class Solver {
		
		int N, p[], exit[];
		int add(int a, int b) { return (a + b) % 1_000_000_007; }
		
		void solve(int testNumber, FastScanner s, PrintWriter out) {
			N = s.nextInt(); p = new int[N]; exit = new int[N];
			for(int i = 0; i < N; i++) p[i] = s.nextInt() - 1;
			
			Arrays.fill(exit, 2);
			int res = 2;
			for(int i = 1; i < N; i++) {
				int j = p[i];
				while(j < i) exit[i] = add(exit[i], exit[j++]);
				res = add(res, exit[i]);
			}
			out.println(res);
		}
 
	}
 
	final static boolean cases = false;
 
	public static void main(String[] args) {
 
		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
 
		Solver solver = new Solver();
		for (int t = 1, T = cases ? s.nextInt() : 1; t <= T; t++)
			solver.solve(t, s, out);
 
		out.close();
 
	}
 
	static int min(int a, int b) {
		return a < b ? a : b;
	}
 
	static int max(int a, int b) {
		return a > b ? a : b;
	}
 
	static long min(long a, long b) {
		return a < b ? a : b;
	}
 
	static long max(long a, long b) {
		return a > b ? a : b;
	}
 
	static int swap(int a, int b) {
		return a;
	}
 
	static Object swap(Object a, Object b) {
		return a;
	}
 
	static String ts(Object... o) {
		return Arrays.deepToString(o);
	}
 
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
 
		public FastScanner(InputStream stream) {
			this.stream = stream;
		}
 
		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}
 
		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}
 
		int read() {
			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++];
		}
 
		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
		public long nextLong() {
			return Long.parseLong(next());
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
 
		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
 
		// Jacob Garbage
 
		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}
 
		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}
 
		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}
 
		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}
 
		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}
 
		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}
 
	}
}