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>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// Description: [1,x]のクエリに対するデータ構造 
// TimeComplexity: 更新$\mathcal{O}(\log n)$ クエリ$\mathcal{O}(\log n)$
// Verifyed: ARC 033 C

struct Binary_indexed_tree{ 
	using T=ll;
	int n; 	
	vector<T> data;
	
	Binary_indexed_tree(int _n):n(_n){data.assign(n+1,0);}
	   
	void add(int i,T x){
		for(;i<=n;i+=i&-i) data[i]+=x;
	}

	T sum(int i){
		T ret=0;
		for(;i>0;i-=i&-i) ret+=data[i];
		return ret;
	}
};

const ll mod=1000000007LL;
const int limit=1<<20;

ll fact[limit];
bool used[limit];
int ary[limit];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> ary[i];
	rep(i,n) used[ary[i]]=true;

	vector<ll> unuse;
	rep(i,1,n+1) if(used[i]==false) unuse.push_back(i);
	const ll k=ll(unuse.size());

	fact[0]=1LL;
	rep(i,1,n+1) fact[i]=1LL*i*fact[i-1]%mod;

	ll ans=fact[k],zero=0LL,sum=0LL;
	Binary_indexed_tree bit(n);

	rrep(i,n){
		ll cur=0LL;
		if(ary[i]){
			cur+=1LL*bit.sum(ary[i])*fact[k]%mod; //(i,j)=(non_zero,non_zero)
			cur+=1LL*zero*(lower_bound(begin(unuse),end(unuse),ary[i])-begin(unuse))%mod*fact[k-1]%mod; //(i,j)=(non_zero,zero)
			bit.add(ary[i],1);
			sum+=1LL*(end(unuse)-lower_bound(begin(unuse),end(unuse),ary[i]))*fact[k-1]%mod; //(i,j)=(zero,non_zero)
			sum%=mod;
		}else{
			ll allsum=(k*(k-1)/2LL)%mod;
			cur+=1LL*allsum*fact[k-2]%mod*zero%mod; //(i,j)=(zero,zero)
			cur+=sum; //(i,j)=(zero,non_zero)
			zero++;
		}
		ans+=cur%mod*fact[n-1-i]%mod;
		ans%=mod;
	}

	cout << ans << endl;
	return 0;
}