#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))

const int mod = 1e9+7;
long long A[100001];

long long pw(int x, int n) {
    long long t=1;
    rep(i,n) t = t*x%mod;
    return t%mod;
}

int main() {
    int N;
    cin >> N;
    rep(i,N) {
        int t; cin >> t; t--;
        A[t]++;
    }


    int cnt=0;
    rep(i,N) {
        if (A[i] > 0 && A[i] != 2) {
            cout << 0 << endl;
            return 0;
        }
        if (A[i] == 2) cnt++;
    }

    cout << pw(2, cnt) << endl;
    return 0;
}
