#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int power(int a, int b, int ans = 1) {
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * ans * a % mod;
  return ans;
}
int a[555], b[555];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != -1) b[a[i]]++;
  }
  long long ans = (power(2, n - 1) + mod - 1) % mod;
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) {
      ans = (ans + mod - power(2, b[i]) + 1) % mod;
    }
  }
  cout << ans << endl;
  return 0;
}
