#include <bits/stdc++.h>
using namespace std;
int a[555], d[555], pw[555];
int main() {
  int n;
  cin >> n;
  int mod = 1e9 + 7;
  for (int i = pw[0] = 1; i <= n; i++) {
    cin >> a[i];
    pw[i] = pw[i - 1] * 2 % mod;
    if (~a[i]) d[a[i]]++;
  }
  int ans = pw[n - 1] - 1;
  for (int i = 1; i <= n; i++)
    if (a[i] == -1) {
      ans -= pw[d[i]] - 1;
      if (ans < 0) ans += mod;
    }
  cout << ans << endl;
}
