#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 2;
const int mod = 1e9 + 7;
void add(int &x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
}
void sub(int &x, int y) {
  x -= y;
  if (x < 0) {
    x += mod;
  }
}
int mul(int x, int y) { return (1ll * x * y) % mod; }
int pw2[N], ar[N], cnt[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, ans;
  cin >> n;
  pw2[0] = 1;
  for (i = 1; i <= n; i++) {
    pw2[i] = mul(pw2[i - 1], 2);
    cin >> ar[i];
    if (ar[i] != -1) {
      cnt[ar[i]]++;
    }
  }
  ans = pw2[n - 1] - 1;
  for (i = 1; i <= n; i++) {
    sub(ans, pw2[cnt[i]] - 1);
  }
  cout << ans;
}
