One day Mr. Takahashi picked up a dictionary containing all of the N! permutations of integers 1 through N. The dictionary has N! pages, and page i (1 ≤ i ≤ N!) contains the i-th permutation in the lexicographical order.

Mr. Takahashi wanted to look up a certain permutation of length N in this dictionary, but he forgot some part of it.

His memory of the permutation is described by a sequence P_1, P_2, ..., P_N. If P_i = 0, it means that he forgot the i-th element of the permutation; otherwise, it means that he remembered the i-th element of the permutation and it is P_i.

He decided to look up all the possible permutations in the dictionary. Compute the sum of the page numbers of the pages he has to check, modulo 10^9 + 7.

Constraints

* 1 ≤ N ≤ 500000
* 0 ≤ P_i ≤ N
* P_i ≠ P_j if i ≠ j (1 ≤ i, j ≤ N), P_i ≠ 0 and P_j ≠ 0.

Input

The input is given from Standard Input in the following format:


N
P_1 P_2 ... P_N


Output

Print the sum of the page numbers of the pages he has to check, as modulo 10^9 + 7.

Examples

Input

4
0 2 3 0


Output

23


Input

3
0 0 0


Output

21


Input

5
1 2 3 5 4


Output

2


Input

1
0


Output

1


Input

10
0 3 0 0 1 0 4 0 0 0


Output

953330050
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

class Add_Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	long long int ret;
	int num;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		v[place] = Update(place * 2) + Update(place * 2 + 1);
		return v[place];
	}
	void Sum(int a, int b, int place) {
		if (l[place] >= a && r[place] <= b) {
			ret += v[place];
			return;
		}
		if (l[place] > b || r[place] < a) return;
		Sum(a, b, place * 2);
		Sum(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Add_Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2)num *= 2;
		l.resize(num);
		r.resize(num);
		v.resize(num, 0);
		Left(1);
		Right(1);
	}
	void Add(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] += num;
		if (!update)return;
		place /= 2;
		while (place) {
			v[place] = v[place * 2] + v[place * 2 + 1];
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int Sum(int a, int b) {
		ret = 0;
		Sum(a, b, 1);
		return ret;
	}
};

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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	vector<long long int>by(N + 1, 1);
	for (int i = 2; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	int zero = 0;
	for (auto i : v)zero += !i;
	long long int ans = by[zero];
	int cnt = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (v[i])continue;
		long long int add = (long long int)cnt * zero*(zero - 1)/2;
		add %= MOD;
		add *= by[N - 1 - i];
		add %= MOD;
		add *= by[zero - 2];
		add %= MOD;
		ans += add;
		ans %= MOD;
		cnt++;
	}
	vector<long long int>sum(N + 1,1);
	sum[0] = 0;
	for (auto i : v) {
		if (i)sum[i]--;
	}
	for (int i = 1; i <= N; i++)sum[i] += sum[i - 1];
	int space = 0;
	//cout << ans << endl;
	vector<long long int>box(N);
	long long int bag = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (!v[i]) {
			space++;
			ans += bag * by[N - i - 1];
			ans %= MOD;
			continue;
		}
		long long int add = by[zero - 1];
		add *= by[N - i - 1];
		add %= MOD;
		add *= space;
		add %= MOD;
		add *= sum[v[i] - 1];
		add %= MOD;
		bag += (zero - sum[v[i] - 1])*by[zero-1];
		bag %= MOD;
		ans += add;
		ans %= MOD;

		//cout << add << endl;
	}
	//cout << ans << endl;
	Add_Segment_Tree asg(N);
	for (int i = N - 1; i >= 0; i--) {
		if (!v[i])continue;
		long long int add = by[zero];
		add *= by[N - i - 1];
		add %= MOD;
		add *= asg.Sum(1, v[i]);
		add %= MOD;
		ans += add;
		ans %= MOD;
		asg.Add(v[i], 1, true);
	}
	cout << ans << endl;
}