#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11, mod = 1e9 + 7;
int n, m, x;
int c[N], ans, t[N];
inline void inc(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (x != -1) ++c[x];
  }
  t[0] = 1;
  for (register int i = 1; i <= n; ++i) t[i] = (t[i - 1] << 1) % mod;
  for (register int i = 1; i <= n; ++i) inc(ans, mod - t[c[i]] + 1);
  inc(ans, t[n - 1] - 1);
  ans = (ans + mod) % mod;
  printf("%d\n", ans);
  return 0;
}
