#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int fa[100010];
int se[100010];
int n;
long long ksm(long long a, int n, long long c = 1) {
  for (; n; n >>= 1, a = a * a % mod)
    if (n & 1) c = c * a % mod;
  return c;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> fa[i];
    if (fa[i] == -1) continue;
    se[fa[i]]++;
  }
  long long anss = ksm(2, n - 1) - 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (ksm(2, se[i]) - 1);
    ans %= mod;
    ans += mod;
    ans %= mod;
  }
  anss -= ans;
  anss %= mod;
  anss += mod;
  anss %= mod;
  cout << anss << endl;
}
