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 <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<>
void add(int& a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<>
void sub(int& a,int b){
	a-=b;
	if(a<0)a+=mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

struct BIT{
	vi d;
	void Init(int n){
		d.assign(n,0);
	}
	void Add(int i,int v){
		while(i<(int)d.size()){
			d[i]+=v;
			i+=(i+1)&(-i-1);
		}
	}
	int Get(int i){
		int ret=0;
		while(i>=0){
			ret+=d[i];
			i-=(i+1)&(-i-1);
		}
		return ret;
	}
};

int main(){
	vector<ll> fact({1});
	FOR(i,1,1141919)
		fact.PB(fact.back()*i%mod);
	auto comb=[&](int a,int b){
		if(a<0||b<0||b>a)
			return 0LL;
		return fact[a]*modInv(fact[b])%mod*modInv(fact[a-b])%mod;
	};
	int n=read();
	vi p;
	vector<bool> canUse(n,true);
	REP(i,n){
		int x=read()-1;
		p.PB(x);
		if(x>=0)
			canUse[x]=false;
	}
	vi w;
	REP(i,n)if(canUse[i])
		w.PB(i);
	ll ans=0;
	BIT bit;
	bit.Init(n);
	ll q=0;
	int sel=0;
	for(int i=n-1;i>=0;i--){
		if(p[i]!=-1){
			int low=bit.Get(p[i]);
			int canSel=lower_bound(w.begin(),w.end(),p[i])-w.begin();
			add(ans,fact[n-1-i]*low%mod*
					comb((int)w.size(),sel)%mod*fact[sel]%mod*fact[(int)w.size()-sel]);
			add(ans,fact[n-1-i]*canSel%mod
					*comb((int)w.size()-1,sel-1)%mod*fact[sel]%mod*fact[(int)w.size()-sel]);
			bit.Add(p[i],1);
			q+=(int)w.size()-canSel;
			q%=mod;
		}else{
			add(ans,fact[n-1-i]*q%mod
					*comb((int)w.size()-1,sel)%mod*fact[sel]%mod*fact[(int)w.size()-1-sel]);
			add(ans,fact[n-1-i]*(((ll)w.size()*((int)w.size()-1)/2)%mod)%mod
					*comb((int)w.size()-1-1,sel-1)%mod*fact[sel]%mod*fact[(int)w.size()-1-sel]);
			sel++;
		}
	}
	cout<<(ans+fact[sel])%mod<<endl;
}
