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