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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Array;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class contest {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);

		int n = in.readInt();
		int arr[] = new int[n];

		for (int i = 0; i < arr.length; i++) {
			arr[i] = in.readInt() - 1;
		}
		int mod = 1000000007;
		long helper[] = new long[n];

		for (int i = 0; i < arr.length; i++) {
			// long sum = 2;
			helper[i] = 2;
			for (int j = arr[i]; j < i; j++) {
				helper[i] = (helper[i] % mod + helper[j] % mod) % mod;
			}
		}

		long ans = 0;
		for (int i = 0; i < helper.length; i++) {
			ans =  (ans%mod + helper[i]%mod)%mod;
		}

		out.printLine(ans);
		
		// for (int i = 0; i < arr.length; i++) {
		// arr[i] = in.readInt();
		// }
		//
		// int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
		// int size = 2 * (int) Math.pow(2, x) - 1;
		//
		// int[] segTree = new int[size];
		//
		// constructTree(arr, segTree, 0, n - 1, 0);
		//
		// System.out.println(getMax(segTree, 0, n - 1, in.readInt(),
		// in.readInt(), 0));
		// int index = in.readInt();
		// int val = in.readInt();
		// int diff = arr[index] - val;
		// updateTree(segTree, 0, n - 1, in.readInt(), arr, 0);

		out.close();
	}

	private static int constructTree(int[] arr, int[] segTree, int low, int high, int point) {
		// TODO Auto-generated method stub
		if (low == high) {
			segTree[point] = arr[low];
			return segTree[point];
		}
		int mid = (low + high) / 2;
		segTree[point] = constructTree(arr, segTree, low, mid, 2 * point + 1)
				+ constructTree(arr, segTree, mid + 1, high, 2 * point + 2);
		return segTree[point];

	}

	private static boolean IsSubMatrix(int[][] bigger, int[][] smaller) {
		for (int i = 0; i < bigger.length - smaller.length + 1; i++) {
			for (int j = 0; j < bigger[i].length - smaller[i].length + 1; j++) {
				boolean check = true;
				for (int k = 0; k < smaller.length; k++) {
					for (int x = 0; x < smaller[k].length; x++) {
						if (bigger[i + k][j + x] != smaller[k][x]) {
							check = false;
							break;
						}
					}
					if (!check) {
						break;
					}
				}
				if (check) {
					return true;
				}
			}
		}
		return false;
	}

	private static int getMax(int segTree[], int low, int high, int Rlow, int Rhigh, int point) {

		if (Rlow <= low && Rhigh >= high) {
			return segTree[point];
		}

		if (high < Rlow || low > Rhigh) {
			return 0;
		}

		int mid = (low + high) / 2;

		return getMax(segTree, low, mid, Rlow, Rhigh, 2 * point + 1)
				+ getMax(segTree, mid + 1, high, Rlow, Rhigh, 2 * point + 2);

	}

	private static int updateTree(int segment[], int low, int high, int i, int diff, int si) {

		return 0;
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

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

		public 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++];
		}

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

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

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

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

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

	private static class OutputWriter {
		private final PrintWriter writer;

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

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object... objects) {
			print(objects);
			writer.println();
		}

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