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