#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T,class ...U>bool chmin(T&a, const U&...bs){const T b(bs...);if(a<=b)return false;a=b;return true;}
template<class T,class ...U>bool chmax(T&a, const U&...bs){const T b(bs...);if(a>=b)return false;a=b;return true;}

const int MOD = (int)(1E9+7);
struct MOD_INT{//{{{
    int val;
    MOD_INT(const int& val=0): val((val%MOD+MOD)%MOD){}
    MOD_INT(const ll& val): val((val%MOD+MOD)%MOD){}
    MOD_INT(const MOD_INT& o): val(o.val){}
    operator int(){return val;}
    MOD_INT pow(int e){
        MOD_INT res(1), b(*this);
        for(; e; e>>=1, b=b*b) if(e&1) res = res * b;
        return res;
    }
    MOD_INT inv(){ return pow(MOD-2); }
    template<class T> MOD_INT operator+(const T o) const {return MOD_INT(val+MOD_INT(o).val);}
    template<class T> MOD_INT operator-(const T o) const {return MOD_INT(val-MOD_INT(o).val);}
    template<class T> MOD_INT operator*(const T o) const {return MOD_INT(((ll)val*MOD_INT(o).val));}
    template<class T> MOD_INT operator/(const T o) const {return *this*MOD_INT(o).inv();}
    friend ostream &operator<<(ostream &os, const MOD_INT val) {return os << val.val;}
};
#define DEFOP(OP) template<class T> MOD_INT& operator OP ## = (MOD_INT& a, T o){return a=a OP o;}
DEFOP(+); DEFOP(-); DEFOP(*); DEFOP(/);
#undef DEFOP
//}}}
typedef MOD_INT mi;

/*
 *  SegTree(int n, Val zero = Val())
 *  SegTree(vector<Val> xs, Val zero = Val())
 *  update(int l, int r, Lazy x) // [l, r) += lazy
 *  Val get(int l, int r)
 */
template<typename Val, typename Lazy>
struct SegTree{//{{{
    const Val zero;
    vector<Val>  values;
    vector<Lazy> lazys;
    vector<bool> has_lazy;
    const int n;
    int offset, N;

    inline Val propagate(const Val &l, const Val &r){
        return l + r;
    }
    inline void apply(Val &val, const Lazy &lazy, const int &l, const int &r){
        val += lazy;
    }
    inline void push(Lazy &old, const Lazy &add){
        old += add;
    }

    inline void push_down(const int &k, const int &ll, const int &rr){
        if(!has_lazy[k]) return;
        if(k < offset){
            if(has_lazy[k*2 + 1]) push(lazys[k*2 + 1], lazys[k]);
            else                  lazys[k*2 + 1] = lazys[k];
            if(has_lazy[k*2 + 2]) push(lazys[k*2 + 2], lazys[k]);
            else                  lazys[k*2 + 2] = lazys[k];
            has_lazy[k*2 + 1] = has_lazy[k*2 + 2] = true;
        }
        apply(values[k], lazys[k], ll, min(rr, n));
        has_lazy[k] = false;
    }

    explicit SegTree(int n, const Val zero = Val()) : n(n), zero(zero){
        N = 1;
        while(N < n) N <<= 1;
        offset = N-1;
        values.assign(N*2, zero);
        lazys.resize(N*2);
        has_lazy.assign(N*2, false);
    }
    explicit SegTree(const vector<Val> &xs, const Val zero = Val()) : SegTree(xs.size(), zero){
        rep(i, n) values[i + offset] = xs[i];
        build(0, n, 0, 0, N);
    }
    const Val &build(const int &l, const int &r, const int &k, const int &ll, const int &rr){
        if(r <= ll || rr <= l) return zero;
        if(rr - ll == 1) return values[k];
        const int mm = (ll + rr) >> 1;
        if(r <= mm) return values[k] = build(l, r, k*2+1, ll, mm);
        if(l >= mm) return values[k] = build(l, r, k*2+2, mm, rr);
        return values[k] = propagate(build(l, r, k*2+1, ll, mm), build(l, r, k*2+2, mm, rr));
    }
    void update(const int &l, const int &r, const Lazy &v){
        update(l, r, v, 0, 0, N);
    }
    void update(const int &l, const int &r, const Lazy &v,
            const int &k, const int &ll, const int &rr){
        push_down(k, ll, rr);
        if(r <= ll || rr <= l) return;
        if(l <= ll && rr <= r){
            if(has_lazy[k]) push(lazys[k], v);
            else            lazys[k] = v;
            has_lazy[k] = true;
            push_down(k, ll, rr);
            return;
        }
        const int mm = (ll + rr) >> 1;
        update(l, r, v, k*2+1, ll, mm);
        update(l, r, v, k*2+2, mm, rr);
        values[k] = propagate(values[k*2+1], values[k*2+2]);
    }

    Val get(const int &l, const int &r){ return get(l, r, 0, 0, N); }
    Val get(const int &l, const int &r,
            const int &k, const int &ll, const int &rr){
        if(r <= ll || rr <= l) return zero;
        push_down(k, ll, rr);
        if(l <= ll && rr <= r) return values[k];
        const int mm = (ll + rr) >> 1;
        if(r <= mm) return get(l, r, k*2+1, ll, mm);
        if(l >= mm) return get(l, r, k*2+2, mm, rr);
        return propagate(get(l, r, k*2+1, ll, mm), get(l, r, k*2+2, mm, rr));
    }
};//}}}

constexpr ll mod = 1000000007;
bool solve(){
    int n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return false;
    }
    vector<int> dp(n+10, 0);
    SegTree<mi, mi> seg(n + 10);
    seg.update(0, 1, 1);
    mi ret = 0;
    rep(i, n) {
        const auto free = seg.get(i, i+1);
        if (i == n-1) {
            // a[n-1] = a[n] = ... = k
            ret += free * n;
            break;
        }
        // a[i]=1, a[i+1] = free
        seg.update(i+1, i+2, free);
        // a[i]=k>1, a[i+1]=...=a[i+k]=1, a[i+k+1] = free where i+k+1 < n
        seg.update(i+3, n, free);
        // a[i]=k>1, a[i+1]=a[i+2]=...=1 and i+k+1 >= n (<=> k >= max(n-i-1, 2))
        ret += free * min(i+2, n-1);
        // a[i]=k>1, a[i+1]=a[i+2]=... > 1
        ret += (free * (n - 1)) * (n - 1);
    }
    cout << ret << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:


Measured memory_bytes: 20864