// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != ds.back()) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
				ds.pb(a[i] / j);
			}
		}
		if (a[i] <= n && a[i] != ds.back()) {
			ds.pb(a[i]);
		}
		sort(all(ds), greater<ll>());
		ds.resize(unique(all(ds)) - ds.begin());
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= i; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= i && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			ans += dp[j];
			ans %= R;
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i]; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
				ds.pb(a[i] / j);
			}
		}
		if (a[i] != ds.back()) {
			ds.pb(a[i]);
		}
		sort(all(ds), greater<ll>());
		ds.resize(unique(all(ds)) - ds.begin());
		for (ll j : ds) {
			if (j > n) {
				continue;
			}
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	ll ans = 0;
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			ans += dp[j - 1];
			ans %= R;
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i]; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
				ds.pb(a[i] / j);
			}
		}
		if (a[i] != ds.back()) {
			ds.pb(a[i]);
		}
		sort(all(ds), greater<ll>());
		ds.resize(unique(all(ds)) - ds.begin());
		for (ll j : ds) {
			if (j > n) {
				continue;
			}
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			ans += dp[j - 1];
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= i; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= i && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	ll ans = 0;
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vector<vll> b;
vector<mll> dp;

ll rec(ll ind, ll x) {
	if (x + 1 > n) {
		return 1;
	}
	if (x && b[x].empty()) {
		return 0;
	}
	if (dp[ind].count(x)) {
		return dp[ind][x];
	}
	ll& ans = dp[ind][x];
	for (ll i : b[x + 1]) {
		if (i <= ind) {
			continue;
		}
		ans += rec(i, x + 1);
		ans %= R;
	}
	if (x) {
		++ans;
	}
	return ans;
}

inline void solve() {
	b.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		b[1].pb(i);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				b[j].pb(i);
			}
		}
		if (a[i] != 1 && a[i] <= n) {
			b[a[i]].pb(i);
		}
	}
	dp.resize(n + 1);
	ll ans = rec(0, 0);
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != ds.back()) {
			ds.pb(a[i]);
		}
		sort(all(ds), greater<ll>());
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			dp[j] += dp[j - 1];
			dp[j] %= R;
		}
	}
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
		ans %= R;
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

ll n;
vll a;
vll dp;

inline void solve() {
	dp.assign(n + 1, 0);
	dp[0] = 1;
	for (ll i = 1; i <= n; i++) {
		vll ds;
		ds.pb(1);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				ds.pb(j);
			}
		}
		if (a[i] <= n && a[i] != 1) {
			ds.pb(a[i]);
		}
		reverse(all(ds));
		for (ll j : ds) {
			dp[j] += dp[j - 1];
		}
	}
	ll ans = 0;
	for (ll j = 1; j <= n; j++) {
		ans += dp[j];
	}
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


// I love meowmur
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define die(cond) if (cond) for (;;){}
#define y1 y_1
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

int main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll R = 1e9 + 7;
ll n;
vll a;
vector<vll> b;
vector<hash_map<ll, ll>> dp;

ll rec(ll ind, ll x) {
	if (x + 1 > n) {
		return 1;
	}
	if (x && b[x].empty()) {
		return 0;
	}
	if (dp[ind].count(x)) {
		return dp[ind][x];
	}
	ll& ans = dp[ind][x];
	for (ll i : b[x + 1]) {
		if (i <= ind) {
			continue;
		}
		ans += rec(i, x + 1);
		ans %= R;
	}
	if (x) {
		++ans;
	}
	return ans;
}

inline void solve() {
	b.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		b[1].pb(i);
		for (ll j = 2; j*j <= a[i] && j <= n; j++) {
			if (a[i] % j == 0) {
				b[j].pb(i);
			}
		}
		if (a[i] != 1 && a[i] <= n) {
			b[a[i]].pb(i);
		}
	}
	dp.resize(n + 1);
	ll ans = rec(0, 0);
	cout << ans << endl;
}

inline void read() {
	cin >> n;
	a.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <numeric>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1e9;
const long long LINF = 1e18;

const int MAXN = 1e5;
const int MOD = 1e9 + 7;

vector<int> A[MAXN];
int n, B[MAXN], ANS[MAXN + 1];

void sieve() {
	for (int i = 1; i < MAXN; i++) {
		for (int j = i; j < MAXN; j += (i + 1)) {
			A[j].push_back(i + 1);
		}
	}
}

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
	}

	sieve();

	ANS[1] = 1;
	pii prev, temp;

	for (int i = 1; i < n; i++) {
		prev = { 1, (ANS[1] + 1) % MOD };

		for (int divisor : A[B[i] - 1]) {
			temp.X = divisor;
			temp.Y = (ANS[divisor] + ANS[divisor - 1]) % MOD;

			ANS[prev.X] = prev.Y;
			prev = temp;
		}

		ANS[prev.X] = prev.Y;
	}

	printf("%d\n", accumulate(ANS + 1, ANS + n + 1, 0, [&](int a, int b) { return (a + b) % MOD; }));

	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <numeric>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1e9;
const long long LINF = 1e18;

const int MAXN = 1e6;
const int MOD = 1e9 + 7;

vector<int> A[MAXN];
int n, B[MAXN], ANS[MAXN + 1];

void sieve() {
	for (int i = 1; i < MAXN; i++) {
		for (int j = i; j < MAXN; j += (i + 1)) {
			A[j].push_back(i + 1);
		}
	}
}

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
	}

	sieve();

	ANS[1] = 1;
	pii prev, temp;

	for (int i = 1; i < n; i++) {
		prev = { 1, (ANS[1] + 1) % MOD };

		for (int divisor : A[B[i] - 1]) {
			temp.X = divisor;
			temp.Y = (ANS[divisor] + ANS[divisor - 1]) % MOD;

			ANS[prev.X] = prev.Y;
			prev = temp;
		}

		ANS[prev.X] = prev.Y;
	}

	printf("%d\n", accumulate(ANS + 1, ANS + n + 1, 0, [&](int a, int b) { return (a + b) % MOD; }));

	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <numeric>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1e9;
const long long LINF = 1e18;

const int MAXN = 1e5;
const int MOD = 1e9 + 7;

vector<int> A[MAXN];
long long n, B[MAXN], ANS[MAXN + 1];

void sieve() {
	for (int i = 1; i < MAXN; i++) {
		for (int j = i; j < MAXN; j += (i + 1)) {
			A[j].push_back(i + 1);
		}
	}
}

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
	}

	sieve();

	ANS[1] = 1;
	pair<long, long> prev, temp;

	for (int i = 1; i < n; i++) {
		prev = { 1, (ANS[1] + 1) % MOD };

		for (int divisor : A[B[i] - 1]) {
			temp.X = divisor;
			temp.Y = (ANS[divisor] + ANS[divisor - 1]) % MOD;

			ANS[prev.X] = prev.Y;
			prev = temp;
		}

		ANS[prev.X] = prev.Y;
	}

	printf("%d\n", accumulate(ANS + 1, ANS + n + 1, 0, [&](int a, int b) { return (a + b) % MOD; }));

	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <numeric>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1e9;
const long long LINF = 1e18;

const int MAXN = 1e5;
const int MOD = 1e9 + 7;

vector<int> A[MAXN];
long long n, B[MAXN], ANS[MAXN + 1];

void sieve() {
	for (int i = 1; i < MAXN; i++) {
		for (int j = i; j < MAXN; j += (i + 1)) {
			A[j].push_back(i + 1);
		}
	}
}

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
	}

	sieve();

	ANS[1] = 1;
	pii prev, temp;

	for (int i = 1; i < n; i++) {
		prev = { 1, (ANS[1] + 1) % MOD };

		for (int divisor : A[B[i] - 1]) {
			temp.X = divisor;
			temp.Y = (ANS[divisor] + ANS[divisor - 1]) % MOD;

			ANS[prev.X] = prev.Y;
			prev = temp;
		}

		ANS[prev.X] = prev.Y;
	}

	printf("%d\n", accumulate(ANS + 1, ANS + n + 1, 0, [&](int a, int b) { return (a + b) % MOD; }));

	return 0;
}


//

#include<string>
#include <iostream>
#include<set>
#include <algorithm>
#include<vector>
#include<map>
#include<cmath>
#include <windows.h>
#include<fstream>
typedef long long ll;
const int nmax = 30000;
const int MAX = 1000000009;
using namespace std;
ofstream out("output.txt", ios::out);
ifstream in("input.txt", ios::in);

//#define x1 first
//#define y1 second
#define MP make_pair
#define PB push_back
#define all(a) (a).begin(), (a).end()

//
//
//
//
//int mmax(int a, int b,int c) {
//	return  max(max(a, b), c);
//}
//
//
//int ex_c(int a, int b) {
//	if (a == 0 && b == 1) {
//		return 2;
//	}
//	if (a == 1 && b == 2) {
//		return 0;
//	}
//	if (a == 0 && b == 2) {
//		return 1;
//	}
//}
//ll gcd(ll a, ll b) {
//	if (b == 0)
//		return a;
//	else
//		return gcd(b, a % b);
//}

//vector<pair<int,int>> g[3*100004];
//vector < pair<int, pair<int, int>>> gr[3*100002];
//int ans= 0;
//int used[3*100007];
//int cv = 0;
//int an[100007];
//int d[3 * 100003];
//int res[110000];
//
//void dfs(int v,int& k) {
//
//	used[v] = 1;
//
//	if (g[v].size() == 1 && (k > 0 && k < 4)) {
//		res[g[v][0].second] = k;
//		///*res[g[v][1].second] = 2;
//		//res[g[v][2].second] = 3;*/
//
//		k++;
//	}
//	for (auto to:g[v]) {
//		if (used[to.first] != 1) {
//			dfs(to.first, k);
//		}
//		}
//	}
//
//
//int pol(string s) {
//	for (int i = 0;i < s.length()/2;i++) {
//		if (s[i] != s[s.length() - i - 1]) {
//			return 0;
//		}
//	}
//	return 1;
//	}
//
//
//void dejstra_bad(int  s, int n ) {
//
//	for (int i = 0;i < n;i++) {
//		int v = -1;
//
//		for (int j = 0;j < n;j++) {
//			if (used[j] != 1 && (v == -1 || d[j] < d[v])) {
//				v = j;
//			}
//		}
//	/*	if (d[v] == MAX) {
//			break;
//		}*/
//		used[v] = 1;
//
//		for (int j = 0;j < gr[v].size();j++) {
//			int to = gr[v][j].first;
//			int len = gr[v][j].second.first;
//			if (d[v] + len < d[to]) {
//				d[to] = d[v] + len;
//
//
//
//			}
//		}
//	}
//
//}
//
//void dejstra(vector<int> &ans,int k,int n) {
//	set<pair<long long, int> > q;
//	vector<long long> d(n, (long long)(1e18));
//	d[0] = 0;
//	q.insert(make_pair(0, 0));
//	vector<int> last(n, -1);
//	int cnt = 0;
//
//	while (!q.empty() && cnt < k)
//	{
//		auto z = *q.begin();
//		q.erase(q.begin());
//		int k = z.second;
//		if (last[k] != -1)
//		{
//			cnt++;
//			ans.push_back(last[k]);
//		}
//		for (auto y : gr[k])
//		{
//			int to = y.first;
//			int w = y.second.first;
//			int idx = y.second.second;
//			if (d[to] > d[k] + w)
//			{
//				q.erase(make_pair(d[to], to));
//				d[to] = d[k] + w;
//				last[to] = idx;
//				q.insert(make_pair(d[to], to));
//			}
//		}
//	}
//
//
//}
//
//
//int modexp(ll x, ll y, ll N) {
//	if (y == 0) {
//		return 1;
//	}
//	ll z = modexp(x, y / 2, N);
//	if (y % 2 == 0) {
//		return (z * z) % N;
//	}
//	else {
//		return (z * z * x) % N;
//	}
//}
//
//int exp(ll x, ll y) {
//	if (y == 0) {
//		return 1;
//	}
//	ll z = exp(x, y / 2);
//	if (y % 2 == 0) {
//		return (z * z);
//	}
//	else {
//		return (z * z * x) ;
//	}
//}
//
//
//
//
//string rev(string s) {
//	string s1;
//	for (int i = s.length() - 1;i >= 0;i--) {
//		s1 += s[i];
//	}
//	return s1;
//}
//
//
//
//
//
//string  loop_rev(string s, int ans,int n) {
//	for (int i = 0;i < n - ans + 1;i++) {
//		string tmp = s.substr(i, ans);
//		tmp = rev(tmp);
//		int tp = 0;
//		for (int j = i;j < i + ans;j++) {
//			s[j] = tmp[tp];
//			tp++;
//		}
//	}
//	return s;
//}
//
//
//vector<ll> find_sub(vector<int>a) {
//
//	int i = 0;
//
//	int n = a.size();
//	vector<ll>res(n + 1);
//	while (i < n) {
//		if (a[i] == 0) {
//			i++;
//			continue;
//		}
//
//		int j = i;
//		while ( j < n && a[j] == 1 ) {
//			j++;
//		}
//
//		for (int len = 1;len <= j - i;len++) {
//			res[len] += j - i - len + 1;
//
//		}
//
//
//		i = j;
//		}
//
//	return res;
//
//
//}

//int T;
//vector<int> par, d;
//vector<vector<int>> g;
//vector<int> tin, tout;
//void dfs_f_t(int v, int p, int dep) {
//
//	tin[v] = T++;
//	d[v] = dep;
//	par[v] = p;
//	for (auto to : g[v]) {
//		if (to == p)  continue;
//		dfs_f_t(to, v,dep+1);
//	}
//	tout[v] = T++;
//}
//
//bool isAnc(int v, int u) {
//	return tin[v] <= tin[u] && tout[v] >= tout[u];
//}

//
//void comivojor(int ind, int n, int& ans, int len, vector<vector<int>> g,vector<int>&p,vector<bool> used) {
//
//	/*if (len >= ans) {
//		return;
//	}*/
//	if (ind == n+1) {
//
//		for (int i = 1;i < n+1;i++) {
//			cout << p[i] << ' ';
//		}
//		ans = min(ans, len + g[p[ind-1]][0]);
//		//len = 0;
//		cout << endl;
//		return;
//	}
//
//	for (int i = 1;i <= n;i++) {
//
//		if (used[i] == true) {
//			continue;
//		}
//
//		p[ind] = i;
//		used[i] = true;
//
//			comivojor(ind + 1, n, ans, len + g[p[ind-1]][i], g, p, used);
//			used[i] = false;
//	}
//}

bool if_in(int x, int l, int r) {
	return l <= x && x <= r;
}

int cnt[1000000+5];
int a[1000000 + 5];
int main()
{

	/* HANDLE hwnd = GetStdHandle(STD_OUTPUT_HANDLE);
	 SetConsoleTextAttribute(hwnd, FOREGROUND_GREEN | FOREGROUND_INTENSITY);*/

	int n;
	cin >> n;

	ll ans = 0;

	cnt[0] = 1;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		vector<int>cur;
			for (int j = 1;j * j <= a[i];j++) {
			if (a[i] % j == 0) {
				cur.PB(j);
				if (j != a[i] / j) {
					cur.PB(a[i] / j);
				}
			}
		}
		sort(cur.rbegin(), cur.rend());
		for (auto& it : cur) {
			cnt[it] += cnt[it - 1];
			cnt[it] %= (1000000000 + 7);
		}
	}
	for (int i = 1;i <= n;i++) {
		ans += cnt[i];
		ans %=  (1000000000 + 7);
	}
	cout << ans;

}

//5 2
//43 2 12 30 46

//1000000000 1000000000 33 434 2 324 32

// Запуск программы: CTRL+F5 или меню "ОтлаB      дка" > "Запуск без отладки"
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"

// Советы по началу работы
//   1. В окне обозревателя решений можно добавлять файлы и управлять ими.
//   2. В окне Team Explorer можно подключиться к системе управления версиями.
//   3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
//   4. В окне "Список ошибок" можно просматривать ошибки.
//   5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
//   6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.


//

#include<string>
#include <iostream>
#include<set>
#include <algorithm>
#include<vector>
#include<map>
#include<cmath>
#include <windows.h>
#include<fstream>
typedef long long ll;
const int nmax = 30000;
const int MAX = 1000000009;
using namespace std;
ofstream out("output.txt", ios::out);
ifstream in("input.txt", ios::in);

//#define x1 first
//#define y1 second
#define MP make_pair
#define PB push_back
#define all(a) (a).begin(), (a).end()

//
//
//
//
//int mmax(int a, int b,int c) {
//	return  max(max(a, b), c);
//}
//
//
//int ex_c(int a, int b) {
//	if (a == 0 && b == 1) {
//		return 2;
//	}
//	if (a == 1 && b == 2) {
//		return 0;
//	}
//	if (a == 0 && b == 2) {
//		return 1;
//	}
//}
//ll gcd(ll a, ll b) {
//	if (b == 0)
//		return a;
//	else
//		return gcd(b, a % b);
//}

//vector<pair<int,int>> g[3*100004];
//vector < pair<int, pair<int, int>>> gr[3*100002];
//int ans= 0;
//int used[3*100007];
//int cv = 0;
//int an[100007];
//int d[3 * 100003];
//int res[110000];
//
//void dfs(int v,int& k) {
//
//	used[v] = 1;
//
//	if (g[v].size() == 1 && (k > 0 && k < 4)) {
//		res[g[v][0].second] = k;
//		///*res[g[v][1].second] = 2;
//		//res[g[v][2].second] = 3;*/
//
//		k++;
//	}
//	for (auto to:g[v]) {
//		if (used[to.first] != 1) {
//			dfs(to.first, k);
//		}
//		}
//	}
//
//
//int pol(string s) {
//	for (int i = 0;i < s.length()/2;i++) {
//		if (s[i] != s[s.length() - i - 1]) {
//			return 0;
//		}
//	}
//	return 1;
//	}
//
//
//void dejstra_bad(int  s, int n ) {
//
//	for (int i = 0;i < n;i++) {
//		int v = -1;
//
//		for (int j = 0;j < n;j++) {
//			if (used[j] != 1 && (v == -1 || d[j] < d[v])) {
//				v = j;
//			}
//		}
//	/*	if (d[v] == MAX) {
//			break;
//		}*/
//		used[v] = 1;
//
//		for (int j = 0;j < gr[v].size();j++) {
//			int to = gr[v][j].first;
//			int len = gr[v][j].second.first;
//			if (d[v] + len < d[to]) {
//				d[to] = d[v] + len;
//
//
//
//			}
//		}
//	}
//
//}
//
//void dejstra(vector<int> &ans,int k,int n) {
//	set<pair<long long, int> > q;
//	vector<long long> d(n, (long long)(1e18));
//	d[0] = 0;
//	q.insert(make_pair(0, 0));
//	vector<int> last(n, -1);
//	int cnt = 0;
//
//	while (!q.empty() && cnt < k)
//	{
//		auto z = *q.begin();
//		q.erase(q.begin());
//		int k = z.second;
//		if (last[k] != -1)
//		{
//			cnt++;
//			ans.push_back(last[k]);
//		}
//		for (auto y : gr[k])
//		{
//			int to = y.first;
//			int w = y.second.first;
//			int idx = y.second.second;
//			if (d[to] > d[k] + w)
//			{
//				q.erase(make_pair(d[to], to));
//				d[to] = d[k] + w;
//				last[to] = idx;
//				q.insert(make_pair(d[to], to));
//			}
//		}
//	}
//
//
//}
//
//
//int modexp(ll x, ll y, ll N) {
//	if (y == 0) {
//		return 1;
//	}
//	ll z = modexp(x, y / 2, N);
//	if (y % 2 == 0) {
//		return (z * z) % N;
//	}
//	else {
//		return (z * z * x) % N;
//	}
//}
//
//int exp(ll x, ll y) {
//	if (y == 0) {
//		return 1;
//	}
//	ll z = exp(x, y / 2);
//	if (y % 2 == 0) {
//		return (z * z);
//	}
//	else {
//		return (z * z * x) ;
//	}
//}
//
//
//
//
//string rev(string s) {
//	string s1;
//	for (int i = s.length() - 1;i >= 0;i--) {
//		s1 += s[i];
//	}
//	return s1;
//}
//
//
//
//
//
//string  loop_rev(string s, int ans,int n) {
//	for (int i = 0;i < n - ans + 1;i++) {
//		string tmp = s.substr(i, ans);
//		tmp = rev(tmp);
//		int tp = 0;
//		for (int j = i;j < i + ans;j++) {
//			s[j] = tmp[tp];
//			tp++;
//		}
//	}
//	return s;
//}
//
//
//vector<ll> find_sub(vector<int>a) {
//
//	int i = 0;
//
//	int n = a.size();
//	vector<ll>res(n + 1);
//	while (i < n) {
//		if (a[i] == 0) {
//			i++;
//			continue;
//		}
//
//		int j = i;
//		while ( j < n && a[j] == 1 ) {
//			j++;
//		}
//
//		for (int len = 1;len <= j - i;len++) {
//			res[len] += j - i - len + 1;
//
//		}
//
//
//		i = j;
//		}
//
//	return res;
//
//
//}

//int T;
//vector<int> par, d;
//vector<vector<int>> g;
//vector<int> tin, tout;
//void dfs_f_t(int v, int p, int dep) {
//
//	tin[v] = T++;
//	d[v] = dep;
//	par[v] = p;
//	for (auto to : g[v]) {
//		if (to == p)  continue;
//		dfs_f_t(to, v,dep+1);
//	}
//	tout[v] = T++;
//}
//
//bool isAnc(int v, int u) {
//	return tin[v] <= tin[u] && tout[v] >= tout[u];
//}

//
//void comivojor(int ind, int n, int& ans, int len, vector<vector<int>> g,vector<int>&p,vector<bool> used) {
//
//	/*if (len >= ans) {
//		return;
//	}*/
//	if (ind == n+1) {
//
//		for (int i = 1;i < n+1;i++) {
//			cout << p[i] << ' ';
//		}
//		ans = min(ans, len + g[p[ind-1]][0]);
//		//len = 0;
//		cout << endl;
//		return;
//	}
//
//	for (int i = 1;i <= n;i++) {
//
//		if (used[i] == true) {
//			continue;
//		}
//
//		p[ind] = i;
//		used[i] = true;
//
//			comivojor(ind + 1, n, ans, len + g[p[ind-1]][i], g, p, used);
//			used[i] = false;
//	}
//}

bool if_in(int x, int l, int r) {
	return l <= x && x <= r;
}

int cnt[1000000+5];
int a[1000000 + 5];
int main()
{

	/* HANDLE hwnd = GetStdHandle(STD_OUTPUT_HANDLE);
	 SetConsoleTextAttribute(hwnd, FOREGROUND_GREEN | FOREGROUND_INTENSITY);*/

	int n;
	cin >> n;

	ll ans = 0;

	cnt[0] = 1;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		vector<int>cur;
			for (int j = 1;j * j <= a[i];j++) {
			if (a[i] % j == 0) {
				cur.PB(j);
				if (j != a[i] / j) {
					cur.PB(a[i] / j);
				}
			}
		}
		//sort(cur.begin(), cur.end());
		for (auto& it : cur) {
			cnt[it] += cnt[it - 1];
			cnt[it] %= (1000000000 + 7);
		}
	}
	for (int i = 1;i <= n;i++) {
		ans += cnt[i];
		ans %=  (1000000000 + 7);
	}
	cout << ans;

}

//5 2
//43 2 12 30 46

//1000000000 1000000000 33 434 2 324 32

// Запуск программы: CTRL+F5 или меню "ОтлаB      дка" > "Запуск без отладки"
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"

// Советы по началу работы
//   1. В окне обозревателя решений можно добавлять файлы и управлять ими.
//   2. В окне Team Explorer можно подключиться к системе управления версиями.
//   3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
//   4. В окне "Список ошибок" можно просматривать ошибки.
//   5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
//   6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <string>

using namespace std;

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef long long ll;

// 1061C

const ll mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	int a;
	int p = 1;
	cin >> n;
	ll ans = 0;
	vector<ll> m(n + 1, 0);
	ll s = 0;
	m[0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> a;
		vi b;
		for (int j = 1; j * j <= a; j++) {
			if (a % j == 0) {
				b.push_back(j);
				if (j != a / j) b.push_back(a / j);
			}
		}
		sort(b.begin(), b.end());
		int len = b.size();
		for (int j = len - 1; j >= 0; j--) {
			if (b[j] > i + 1) continue;
			m[b[j]] = (m[b[j]] + m[b[j] - 1]) % mod;
		}
	}
	for (int i = 1; i <= n; i++) {
		ans = (ans + m[i]) % mod;
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;

#undef int
int main(){
#define int long long
    int n,m;
    cin>>n>>m;
    int a[n][m],b[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        cin >> b[i][j];
    bool flag=1;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < m; j++){
        if(a[i][j]>b[i][j])
            swap(a[i][j],b[i][j]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (i>0&&a[i][j]<=a[i-1][j]) flag=0;
        if (j>0&&a[i][j]<=a[i][j-1]) flag=0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (i > 0 && b[i][j] <= b[i - 1][j])
          flag = 0;
        if (j > 0 && b[i][j] <= b[i][j - 1])
          flag = 0;
      }
    }
    if(flag)
        cout<<"Possible";
    else
        cout<<"Impossible";
    return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

#undef int
int main() {
#define int long long
  int n,m;
  cin>>n>>m;
  int a1[n][100],a2[n][100],b1[n][100],b2[n][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
        cin>>a1[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
        cin>>a2[i][j];
  for(int i=0;i<n;i++)
  {
      for(int j=0;j<m;j++)
      {
          if(a1[i][j]>a2[i][j])
            swap(a1[i][j],a2[i][j]);
      }
  }
  for(int i=0;i<n;i++)
  {
      for(int j=1;j<m;j++)
      {
          if(a1[i][j]<=a1[i][j-1]||a2[i][j]<=a2[i][j-1]){
            cout << "Impossible";
            return 0;
          }

      }
  }
  for (int i = 0; i <  m; i++) {
    for (int j = 1; j < n; j++) {
      if (a1[j][i] <= a1[j][i - 1] || a2[j][i] <= a2[j][i - 1]) {
        cout << "Impossible";
        return 0;
      }
    }
  }
  cout<<"Possible";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int a[55][55],b[55][55];

int main(){
    IO;
    int n,m;cin>>n>>m;
    forn(i,n)forn(j,m)cin>>a[i][j];
    forn(i,n)forn(j,m)cin>>b[i][j];
    bool ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;

    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]){
                a[i][j] = b[i][j];
            }
            if(b[i][j]>=b[i][j+1]){
                b[i][j] = a[i][j];
            }
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]){
                a[i][j] = b[i][j];
            }
            if(b[i][j]>=b[i+1][j]){
                b[i][j] = a[i][j];
            }
        }
    }
    ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;
    cout <<"Impossible"<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main(){
    IO;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int a[55][55],b[55][55],c[55][55],d[55][55];

int main(){
    IO;
    int n,m;cin>>n>>m;
    forn(i,n)forn(j,m){
        cin>>a[i][j];
    }
    forn(i,n)forn(j,m)cin>>b[i][j];
    bool ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;

    forn(i,n){
        forn(j,m){
            if(a[i][j]>b[i][j]){
                swap(a[i][j],b[i][j]);
            }
        }
    }

    ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;
    cout <<"Impossible"<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int a[55][55],b[55][55];

int main(){
    IO;
    int n,m;cin>>n>>m;
    forn(i,n)forn(j,m)cin>>a[i][j];
    forn(i,n)forn(j,m)cin>>b[i][j];
    bool ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;

    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]){
                if(a[i][j]>b[i][j]) swap(a[i][j],b[i][j]);
                if(a[i][j+1]>b[i][j+1]) swap(a[i][j+1],b[i][j+1]);
            }
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]){
                if(a[i][j]>b[i][j]) swap(a[i][j],b[i][j]);
                if(a[i+1][j]>b[i][j]) swap(a[i+1][j],b[i+1][j]);
            }
        }
    }
    ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;
    cout <<"Impossible"<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int a[55][55],b[55][55];

int main(){
    IO;
    int n,m;cin>>n>>m;
    forn(i,n)forn(j,m)cin>>a[i][j];
    forn(i,n)forn(j,m)cin>>b[i][j];
    bool ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;

    forn(i,n){
        for(int j = m-2;j>=0;j--){
            if(a[i][j]>=a[i][j+1]){
                a[i][j] = b[i][j];
            }
            if(b[i][j]>=b[i][j+1]){
                b[i][j] = a[i][j];
            }
        }
    }
    forn(j,m){
        for(int i = n-2;i>=0;i--){
            if(a[i][j]>=a[i+1][j]){
                a[i][j] = b[i][j];
            }
            if(b[i][j]>=b[i+1][j]){
                b[i][j] = a[i][j];
            }
        }
    }
    ok = 1;
    forn(i,n){
        forn(j,m-1){
            if(a[i][j]>=a[i][j+1]) ok = 0;
            if(b[i][j]>=b[i][j+1]) ok = 0;
        }
    }
    forn(j,m){
        forn(i,n-1){
            if(a[i][j]>=a[i+1][j]) ok = 0;
            if(b[i][j]>=b[i+1][j]) ok = 0;
        }
    }
    if(ok) return cout <<"Possible"<<'\n',0;
    cout <<"Impossible"<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    ll a[n][m], b[n][m];
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            cin >> a[i][j];
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            cin >> b[i][j];
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            if(a[i][j]>=b[i][j])
                swap(a[i][j], b[i][j]);
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
        {
        if(i && (a[i][j]<=a[i-1][j] || b[i][j]<=b[i-1][j]))
        {
            cout << "Impossible" << endl;
            return 0;
        }
        if(j && (a[i][j]<=a[i][j-1] || b[i][j]<=b[i][j-1]))
        {
            cout << "Impossible" << endl;
            return 0;
        }
        }
    cout << "Possible" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, m;
    cin >> n >> m;
    set <ll> mc;
    multiset <ll> mp;
    ll x, sum=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(auto i:mc)
    {
        ll k=mp.count(i);
        if(k>n || k>m)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n][m], b[n][m];
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> a[i][j];
      }
  }
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> b[i][j];
      }
  }
  for(int i=0; i<n-1; i++)
  {

      for(int j=0; j<m-1; j++)
      {
          if(a[i][j]>a[i+1][j] || a[i][j]>a[i][j+1])
          {
              ll x=b[i][j];
              if(x>a[i+1][j] || x>a[i][j+1])
              {
                  cout << "Impossible" << endl;
                   return 0;
              }

                  if(a[i][j]>b[i+1][j] || a[i][j]>b[i][j+1])
                    {
                        cout << "Impossible" << endl;
                        return 0;
                    }

          }
          if(b[i][j]>b[i+1][j] || b[i][j]>b[i][j+1])
          {
              ll x=a[i][j];
              if(x>b[i+1][j] || x>b[i][j+1])
              {
                  cout << "Impossible" << endl;
                  return 0;
              }

                  if(b[i][j]>a[i+1][j] || b[i][j]>a[i][j+1])
                  {
                      cout << "Impossible" << endl;
                      return 0;
                  }

          }

      }
  }
  cout << "Possible" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, m;
    cin >> n >> m;
    set <ll> mc;
    multiset <ll> mp;
    ll x;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(auto i:mc)
    {
        ll k=mp.count(i);
        if(k>2)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n][m], b[n][m];
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> a[i][j];
      }
  }
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> b[i][j];
      }
  }
  for(int i=0; i<n-1; i++)
  {

      for(int j=0; j<m-1; j++)
      {
          if(a[i][j]>=a[i+1][j] || a[i][j]>=a[i][j+1])
          {
              ll x=b[i][j];
              if(x>=a[i+1][j] || x>=a[i][j+1])
              {
                  cout << "Impossible" << endl;
                   return 0;
              }
              else
              {
                  if(a[i][j]>=b[i+1][j] || a[i][j]>=b[i][j+1])
                    {
                        cout << "Impossible" << endl;
                        return 0;
                    }
              }
          }
          if(b[i][j]>=b[i+1][j] || b[i][j]>=b[i][j+1])
          {
              ll x=a[i][j];
              if(x>=b[i+1][j] || x>=b[i][j+1])
              {
                  cout << "Impossible" << endl;
                  return 0;
              }
              else
              {
                  if(b[i][j]>=a[i+1][j] || b[i][j]>=a[i][j+1])
                  {
                      cout << "Impossible" << endl;
                      return 0;
                  }
              }
          }

      }
  }
  cout << "Possible" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n][m], b[n][m];
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> a[i][j];
      }
  }
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> b[i][j];
      }
  }
  for(int i=0; i<n-1; i++)
  {

      for(int j=0; j<m-1; j++)
      {
          if(a[i][j]>a[i+1][j] || a[i][j]>a[i][j+1])
          {
              int x=b[i][j];
              if(x>a[i+1][j] || x>a[i][j+1])
              {
                  cout << "Impossible" << endl;
                   return 0;
              }
              else
              {
                  if(a[i][j]>b[i+1][j] || a[i][j]>b[i][j+1])
                    {
                        cout << "Impossible" << endl;
                        return 0;
                    }
              }
          }
          if(b[i][j]>b[i+1][j] || b[i][j]>b[i][j+1])
          {
              int x=a[i][j];
              if(x>b[i+1][j] || x>b[i][j+1])
              {
                  cout << "Impossible" << endl;
                  return 0;
              }
              else
              {
                  if(b[i][j]>a[i+1][j] || b[i][j]>a[i][j+1])
                  {
                      cout << "Impossible" << endl;
                      return 0;
                  }
              }
          }

      }
  }
  cout << "Possible" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, m;
    cin >> n >> m;
    set <ll> mc;
    multiset <ll> mp;
    ll x, sum=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> x;
            mc.insert(x);
            mp.insert(x);
        }
    }
    for(auto i:mc)
    {
        ll k=mp.count(i);
        if(k>1)
            sum=sum+k-1;
        if(sum>=2*n || sum>=2*m)
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n][m], b[n][m];
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> a[i][j];
      }
  }
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> b[i][j];
      }
  }
  for(int i=0; i<n-1; i++)
  {

      for(int j=0; j<m-1; j++)
      {
          if(a[i][j]>a[i+1][j] || a[i][j]>a[i][j+1])
          {
              ll x=b[i][j];
              if(x>a[i+1][j] || x>a[i][j+1])
              {
                  cout << "Impossible" << endl;
                   return 0;
              }

                  if(a[i][j]>b[i+1][j] || a[i][j]>b[i][j+1])
                    {
                        cout << "Impossible" << endl;
                        return 0;
                    }
                swap(a[i][j], b[i][j]);

          }
          if(b[i][j]>b[i+1][j] || b[i][j]>b[i][j+1])
          {
              ll x=a[i][j];
              if(x>b[i+1][j] || x>b[i][j+1])
              {
                  cout << "Impossible" << endl;
                  return 0;
              }

                  if(b[i][j]>a[i+1][j] || b[i][j]>a[i][j+1])
                  {
                      cout << "Impossible" << endl;
                      return 0;
                  }
                swap(a[i][j], b[i][j]);
          }

      }
  }
  cout << "Possible" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  ll a[n][m], b[n][m];
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> a[i][j];
      }
  }
  for(int i=0; i<n; i++)
  {
      for(int j=0; j<m; j++)
      {
          cin >> b[i][j];
      }
  }
  for(int i=0; i<n-1; i++)
  {

      for(int j=0; j<m-1; j++)
      {
          if(a[i][j]>a[i+1][j] || a[i][j]>a[i][j+1])
          {
              ll x=b[i][j];
              if(x>a[i+1][j] || x>a[i][j+1])
              {
                  cout << "Impossible" << endl;
                   return 0;
              }
              else
              {
                  if(a[i][j]>b[i+1][j] || a[i][j]>b[i][j+1])
                    {
                        cout << "Impossible" << endl;
                        return 0;
                    }
              }
          }
          if(b[i][j]>b[i+1][j] || b[i][j]>b[i][j+1])
          {
              ll x=a[i][j];
              if(x>b[i+1][j] || x>b[i][j+1])
              {
                  cout << "Impossible" << endl;
                  return 0;
              }
              else
              {
                  if(b[i][j]>a[i+1][j] || b[i][j]>a[i][j+1])
                  {
                      cout << "Impossible" << endl;
                      return 0;
                  }
              }
          }

      }
  }
  cout << "Possible" << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;

    int a[n][m],b[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];

    int check2=0;
    for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1]) swap(a[i][j-1],b[i][j-1]);

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i]) swap(a[j-1][i],b[j-1][i]);

   for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1] || b[i][j]<=b[i][j-1]) check2=1;

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i] || b[j][i]<=b[j-1][i]) check2=1;

    if(check2==0) cout<<"Posiible";
        else cout<<"Impossible";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n][m],b[n][m];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(a[i][j]>b[i][j]) swap(a[i][j],b[i][j]);

    ll check2=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i<n-1)
            {
                if((a[i][j]<a[i+1][j] && b[i][j]<b[i+1][j])){}
                else check2=1;
            }
            if(j<m-1)
            {
                if(((a[i][j]<a[i][j+1] && b[i][j]<b[i][j+1]))){}
                else check2=1;
            }
        }
    }
    if(check2==0) cout<<"Possible";
    else          cout<<"Impossible";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n][m],b[n][m];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(a[i][j]>b[i][j]) swap(a[i][j],b[i][j]);
    ll check2=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i<n-1 && j<n-1)
            {
                if(((a[i][j]<a[i+1][j] && b[i][j]<b[i+1][j]) && (a[i][j]<a[i][j+1] && b[i][j]<b[i][j+1]))){}
                else check2=1;
            }
            else if(i<n-1)
            {
                if((a[i][j]<a[i+1][j] && b[i][j]<b[i+1][j])){}
                else check2=1;
            }
            else if(j<n-1)
            {
                if(((a[i][j]<a[i][j+1] && b[i][j]<b[i][j+1]))){}
                else check2=1;
            }
        }
    }
    if(check2==0) cout<<"Possible";
    else          cout<<"Impossible";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;

    ll a[n][m],b[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];

    int check2=0;
    for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1] || b[i][j]<=b[i][j-1]) swap(a[i][j-1],b[i][j-1]);

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i] || b[j][i]<=b[j-1][i]) swap(a[j-1][i],b[j-1][i]);

   for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1] || b[i][j]<=b[i][j-1]) check2=1;

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i] || b[j][i]<=b[j-1][i]) check2=1;

    if(check2==0) cout<<"Possible";
        else cout<<"Impossible";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;

    int a[n][m],b[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];

    int check2=0;
    for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1]) swap(a[i][j-1],b[i][j-1]);

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i]) swap(a[j-1][i],b[j-1][i]);

   for(int i=0;i<n;i++)
        for(int j=1;j<m;j++)
            if(a[i][j]<=a[i][j-1] || b[i][j]<=b[i][j-1]) check2=1;

    for(int i=0;i<m;i++)
        for(int j=1;j<n;j++)
            if(a[j][i]<=a[j-1][i] || b[j][i]<=b[j-1][i]) check2=1;

    if(check2==0) cout<<"Possible";
        else cout<<"Impossible";
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>a[i][j+1] || b[i][j] > b[i][j+1])
                        swap(a[i][j],b[i][j]);

            }
    }

    for(i = 1;i<=n-1; i++){
        for(j = 1;j<=m;j++){
            if(a[j][i]>a[j][i+1] || b[j][i]>b[j][i+1])
                swap(a[j][i],b[j][i]);
        }
    }

}

bool f1 = 0 ,f2 = 0;
void fun2()
{

        int i,j;
        for(i = 1;i<=n;i++){
                for(j = 1;j<=m-1;j++){
                    if(a[i][j]>a[i][j+1] || b[i][j] > b[i][j+1]) f1 = 1;
                }
        }

        for(i = 1;i<=n-1; i++){
            for(j = 1;j<=m;j++){
                if(a[j][i]>a[j][i+1] || b[j][i]>b[j][i+1]) f2=1;
            }
        }

}

void solve()
{
        fun1();
        fun2();
        if(f1==0&&f2==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;

}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

int t1 = 0,t2 =0;
void  fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1]){
                        swap(a[i][j],b[i][j]);
                        if(a[i][j]>=a[i][j+1] || b[i][j]>=b[i][j+1]){
                            t1 = 1;
                            break;
                        }

                    }

                    if(b[i][j]>=b[i][j+1]){
                        swap(a[i][j],b[i][j]);
                        if(a[i][j]>=a[i][j+1] || b[i][j]>=b[i][j+1]){
                            t2 = 1;
                            break;
                        }
                    }

            }
    }

    for(i = 1;i<=m; i++){
        for(j = 1;j<=n-1;j++){
            if(a[j][i]>=a[j+1][i]){
                swap(a[j][i],b[j][i]);
                if(a[j][i] >= a[j+1][i] || b[j][i]>=b[j+1][i]){
                    t1 = 1;
                    break;
                }
            }

            if(b[j][i] >= b[j+1][i]){
                swap(b[j][i],b[j+1][i]);
                if(a[j][i] >= a[j+1][i] || b[j][i]>=b[j+1][i]){
                    t2 = 1;
                    break;
                }
            }
        }
    }

}

void solve()
{
        fun1();
        if(t1 ==1 || t2==1)cout<<"Impossible"<<endl;
        else cout<<"Possible"<<endl;
}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1])
                        swap(a[i][j],b[i][j]);

            }
    }

    for(i = 1;i<=n-1; i++){
        for(j = 1;j<=m;j++){
            if(a[j][i]>=a[j][i+1] || b[j][i]>=b[j][i+1])
                swap(a[j][i],b[j][i]);
        }
    }

}

bool f1 = 0 ,f2 = 0;
void fun2()
{

        int i,j;
        for(i = 1;i<=n;i++){
                for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]) f1 = 1;
                }
        }

        for(i = 1;i<=n-1; i++){
            for(j = 1;j<=m;j++){
                if(a[j][i]>=a[j][i+1] || b[j][i]>=b[j][i+1]) f2=1;
            }
        }

}

void solve()
{
        fun1();
        fun2();
        if(f1==0&&f2==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;

}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]){
                        //cout<<"swap hocche "<<endl;
                        swap(a[i][j],b[i][j]);
                    }

            }
    }

    for(i = 1;i<=m; i++){
        for(j = 1;j<=n-1;j++){
            if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]){
                //cout<<"swap hocche "<<endl;
                swap(a[j][i],b[j][i]);
            }
        }
    }

}

bool f1 = 0 ,f2 = 0;
void fun2()
{

        int i,j;
        for(i = 1;i<=n;i++){
                for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]) f1 = 1;
                }
        }

        for(i = 1;i<=m; i++){
            for(j = 1;j<=n-1;j++){
                if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]) f2=1;
            }
        }

}

void solve()
{
        fun1();
        fun2();
        if(f1==0||f2==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;

}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

int t1 = 0,t2 =0;
void  fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1]){
                        swap(a[i][j],b[i][j]);
                        if(a[i][j]>=a[i][j+1] || b[i][j]>=b[i][j+1]){
                            t1 = 1;
                            break;
                        }

                    }

                    if(b[i][j]>=b[i][j+1]){
                        swap(a[i][j],b[i][j]);
                        if(a[i][j]>=a[i][j+1] || b[i][j]>=b[i][j+1]){
                            t2 = 1;
                            break;
                        }
                    }

            }
    }

    for(i = 1;i<=m; i++){
        for(j = 1;j<=n-1;j++){
            if(a[j][i]>=a[j+1][i]){
                swap(a[j][i],b[j][i]);
                if(a[j][i] >= a[j+1][i] || b[j][i]>=b[j+1][i]){
                    t1 = 1;
                    break;
                }
            }

            if(b[j][i] >= b[j+1][i]){
                swap(a[j][i],b[j][i]);
                if(a[j][i] >= a[j+1][i] || b[j][i]>=b[j+1][i]){
                    t2 = 1;
                    break;
                }
            }
        }
    }

}

void solve()
{
        fun1();
        if(t1 ==1 || t2==1)cout<<"Impossible"<<endl;
        else cout<<"Possible"<<endl;
}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]){
                        //cout<<"swap hocche "<<endl;
                        swap(a[i][j],b[i][j]);
                    }

            }
    }

    for(i = 1;i<=m; i++){
        for(j = 1;j<=n-1;j++){
            if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]){
                //cout<<"swap hocche "<<endl;
                swap(a[j][i],b[j][i]);
            }
        }
    }

}

bool f1 = 0 ,f2 = 0;
void fun2()
{

        int i,j;
        for(i = 1;i<=n;i++){
                for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]) f1 = 1;
                }
        }

        for(i = 1;i<=m; i++){
            for(j = 1;j<=n-1;j++){
                if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]) f2=1;
            }
        }

}

void solve()
{
        fun1();
        fun2();

        if(f1==1|| f2==1)cout<<"Impossible"<<endl;
        else cout<<"Possible"<<endl;

}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool isOk1()
{
        bool f1 = 0,f2 =0;
        int i ,j;
        for(i =1 ;i<=n;i++){
                for(j=1;j<=m &&j+1<=m;j++){
                    if(j+1<=m && a[i][j]<a[i][j+1])continue;
                    else f1=1 ;
                }
        }

        for(i =1 ;i<=n;i++){
                for(j=1;j<=m &&j+1<=n;j++){
                    if(j+1<=n && a[j][i]<a[j+1][i])continue;
                    else f1=1 ;
                }
        }

        if(f1==0 && f2==0)return 1;
        return 0;

}

bool isOk2()
{
        bool f1 = 0,f2 =0;
        int i ,j;
        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=m;j++){
                    if(j+1<=m && b[i][j]<b[i][j+1])continue;
                    else f1=1 ;
                }
        }

        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=n;j++){
                    if(j+1<=n && b[j][i]<b[j+1][i])continue;
                    else f1=1 ;
                }
        }

        if(f1==0 && f2==0)return 1;
        return 0;

}

void fun1()
{
        int i ,j;
        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=m;j++){
                    if(j+1<=m && a[i][j]<a[i][j+1])continue;
                    else {
                        if(j+1<=m){
                            swap(a[i][j+1],b[i][j+1]);
                        }
                    }
                }
        }

        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=n;j++){
                    if(j+1<=n && a[j][i]<a[j+1][i])continue;
                    else {
                        if(j+1<=n){
                            swap(a[j+1][i],b[j+1][i]);
                        }
                    }
                }
        }

}

void fun2()
{
        int i ,j;
        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=m;j++){
                    if(j+1<=m && b[i][j]<b[i][j+1])continue;
                    else {
                        if(j+1<=m){
                            swap(a[i][j+1],b[i][j+1]);
                        }
                    }
                }
        }

        for(i =1 ;i<=n;i++){
                for(j=1;j<=m && j+1<=n;j++){
                    if(j+1<=n && b[j][i]<b[j+1][i])continue;
                    else {
                        if(j+1<=n){
                            swap(a[j+1][i],b[j+1][i]);
                        }
                    }
                }
        }

}

void solve()
{
        if(isOk1() && isOk2())cout<<"Possible"<<endl;
        else{
            fun1();
            if(isOk1()&&isOk2())cout<<"Possible"<<endl;
            else{
                fun2();
                if(isOk1()&&isOk2())cout<<"Possible"<<endl;
                else cout<<"Impossible"<<endl;
            }
        }
}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


/**OOO**/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000

int n,m;
int a[55][55];
int b[55][55];

void input()
{
    cin>>n>>m;
    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>a[i][j];
        }
    }

    for(int i =1 ;i<=n;i++){
        for(int j =1;j<=m; j++){
            cin>>b[i][j];
        }
    }
}

bool fun1()
{
    int i,j;
    for(i = 1;i<=n;i++){
            for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]){
                        //cout<<"swap hocche "<<endl;
                        swap(a[i][j],b[i][j]);
                    }

            }
    }

    for(i = 1;i<=m; i++){
        for(j = 1;j<=n-1;j++){
            if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]){
                //cout<<"swap hocche "<<endl;
                swap(a[j][i],b[j][i]);
            }
        }
    }

}

bool f1 = 0 ,f2 = 0;
void fun2()
{

        int i,j;
        for(i = 1;i<=n;i++){
                for(j = 1;j<=m-1;j++){
                    if(a[i][j]>=a[i][j+1] || b[i][j] >= b[i][j+1]) f1 = 1;
                }
        }

        for(i = 1;i<=m; i++){
            for(j = 1;j<=n-1;j++){
                if(a[j][i]>=a[j+1][i] || b[j][i]>=b[j+1][i]) f2=1;
            }
        }

}

void solve()
{
        fun1();
        fun2();
        if(f1==0&&f2==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;

}

int main()
{
        input();
        solve();

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}


#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int a[55][55], b[55][55];

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	cin >> n >> m;

	vi x = { 1, 0 };
	vi y = { 0, 1 };

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int z = 0; z < 2; z++)
			{
				int f = i + x[z];
				int s = j + y[z];

				if (f < n && f >= 0 && s < m && s >= 0)
				{
					if (a[i][j] >= a[f][s] && b[i][j] < a[f][s])
					{
						swap(a[i][j], b[i][j]);
					}
				}
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int z = 0; z < 2; z++)
			{
				int f = i + x[z];
				int s = j + y[z];

				if (f < n && f >= 0 && s < m && s >= 0)
				{
					if (b[i][j] >= b[f][s] && a[i][j] < b[f][s])
					{
						swap(a[i][j], b[i][j]);
					}
				}
			}
		}
	}

	bool fl = true;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m-1; j++)
		{
			if (a[i][j] >= a[i][j + 1] || b[i][j] >= b[i][j + 1])
			{
				fl = false;
				break;
			}
		}
	}

	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < n-1; i++)
		{
			if (a[i][j] >= a[i+1][j] || b[i][j] >= b[i+1][j])
			{
				fl = false;
				break;
			}
		}
	}

	if (fl)
	{
		cout << "Posssible";
	}
	else
	{
		cout << "Impossible";
	}
	return 0;
}


#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int a[55][55], b[55][55];

bool nsw[55][55], sw[55][55];

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	cin >> n >> m;

	for (int i = 0; i < 55; i++)
	{
		for (int j = 0; j < 55; j++)
		{
			a[i][j] = oo;
			b[i][j] = oo;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> b[i][j];
			if (a[i][j] > b[i][j])
				swap(a[i][j], b[i][j]);
		}
	}

	bool fl = true;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (j > 0)
			{
				if (a[i][j] <= a[i][j - 1] || b[i][j] <= b[i][j - 1])
				{
					fl = false;
					break;
				}
			}
			if (i > 0)
			{
				if (a[i][j] <= a[i-1][j] || b[i][j] <= b[i-1][j])
				{
					fl = false;
					break;
				}
			}
		}
	}

	if (fl)
	{
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}
	return 0;
}


#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int a[55][55], b[55][55];

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	cin >> n >> m;

	vi x = { 1, 0 };
	vi y = { 0, 1 };

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int z = 0; z < 2; z++)
			{
				int f = i + x[z];
				int s = j + y[z];

				if (f < n && f >= 0 && s < m && s >= 0)
				{
					if (a[i][j] >= a[f][s] && b[i][j] < a[f][s])
					{
						swap(a[i][j], b[i][j]);
					}
				}
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int z = 0; z < 2; z++)
			{
				int f = i + x[z];
				int s = j + y[z];

				if (f < n && f >= 0 && s < m && s >= 0)
				{
					if (b[i][j] >= b[f][s] && a[i][j] < b[f][s])
					{
						swap(a[i][j], b[i][j]);
					}
				}
			}
		}
	}

	bool fl = true;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m-1; j++)
		{
			if (a[i][j] >= a[i][j + 1] || b[i][j] >= b[i][j + 1])
			{
				fl = false;
				break;
			}
		}
	}

	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < n-1; i++)
		{
			if (a[i][j] >= a[i+1][j] || b[i][j] >= b[i+1][j])
			{
				fl = false;
				break;
			}
		}
	}

	if (fl)
	{
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}
	return 0;
}