#include <bits/stdc++.h>
using namespace std;
using INT = long long;
const int mod = 1e9 + 7;
int c(int n) {
  int ans = 1;
  for (int i = 1; i <= n; i++) ans = ans * 2 % mod;
  return ans;
}
int cnt[11111];
int main() {
  int n;
  cin >> n;
  int k = 0;
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    if (u != -1) cnt[u]++;
  }
  int ans = c(n - 1) - 1;
  for (int i = 1; i <= n; i++)
    if (cnt[i] > 0) {
      ans = (ans - c(cnt[i]) + 1 + mod) % mod;
    }
  cout << ans << endl;
}
