import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Sherlock { public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t = 1; precompute(); while (t-- > 0) { long ways[] = new long[1205]; for (int i = 1; i <= 1204; i++) { for (int j = 1; j <= i; j++) { if (i % j == 0) { ways[i] = ways[i] + mp(j, i / j); ways[i] %= MOD; } } } int n = in.nextInt(); int a[] = new int[n + 1]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } int j = 0; int cnt = 0; long ans = 1; while (j < n) { if (a[j] < a[j + 1]) { j++; cnt++; } else { ans = ans * ways[cnt+1]; ans = ans % MOD; cnt = 0; j++; } } System.out.println(ans); } out.close(); } static double dist(Pair x, Pair y) { return (Math.sqrt((double) (x.x - y.x) * (x.x - y.x) + (double) (x.y - y.y) * (x.y - y.y))); } static int MOD = (int) (1e9 + 7); static long dp[]; static class Pair { int x; int y; int h; Pair(int x, int y, int h) { this.x = x; this.y = y; this.h = h; } } static long mp(long a, long b) { long ans = 1; while (b != 0) { if (b % 2 == 1) ans = (ans * a) % MOD; a = (a * a) % MOD; b /= 2; } return ans % MOD; } static long fac[], ifac[]; static void precompute() { int i; int N = 1000005; fac = new long[N]; ifac = new long[N]; fac[0] = 1; for (i = 1; i < N; i++) { fac[i] = (i * fac[i - 1]) % MOD; } ifac[N - 1] = mp(fac[N - 1], MOD - 2); for (i = N - 2; i >= 0; i--) { ifac[i] = ((i + 1) * ifac[i + 1]) % MOD; } } public static long combine(int n, int k) { if (k > n - k) { k = n - k; } long result = 1; for (int i = 0; i < k; i++) { result *= (n - i); result /= (i + 1); } return result; } static long mInv(long A) { return mp(A, MOD - 2); } static long mC(int n, int k) { // calculates C(n,k) mod p (assuming p is prime). // if(k>n-k)k=n-k; long an; // n * (n-1) * ... * (n-k+1) if (k <= 0) return 1; if (n < k) return 0; an = fac[n] % MOD; an *= ifac[n - k]; an %= MOD; an *= ifac[k]; an %= MOD; // numerator / denominator mod p. return an; } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int read() { if (numChars == Long.MIN_VALUE) 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 int nextInt() { 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 long nextLong() { int c = read(); while (isSpaceChar(c)) c = read(); int 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 String nextToken() { 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 boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return isWhitespace(c); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }