#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int n = 1e6;
int a[n];
int main() {
for(int i = 0; i < n; i++) {
a[i] = rand() % mod;
}
int s = 0;
for(int rep = 0; rep < 50123; ++rep) {
a[rand()%n] = rand() % mod;
int start = rand() % n;
s += a[start];
for(int j = start; j < min(n, start + 9000); j++) {
// s = (s + a[j] < mod ? s+a[j] : s+a[j]-mod);
s = (s + a[j]) % mod;
}
}
cout << s << endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbW9kID0gMWU5ICsgNzsKY29uc3QgaW50IG4gPSAxZTY7CmludCBhW25dOwoKaW50IG1haW4oKSB7Cglmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CgkJYVtpXSA9IHJhbmQoKSAlIG1vZDsKCX0KCWludCBzID0gMDsKCWZvcihpbnQgcmVwID0gMDsgcmVwIDwgNTAxMjM7ICsrcmVwKSB7CgkJYVtyYW5kKCklbl0gPSByYW5kKCkgJSBtb2Q7CgkJaW50IHN0YXJ0ID0gcmFuZCgpICUgbjsKCQlzICs9IGFbc3RhcnRdOwoJCWZvcihpbnQgaiA9IHN0YXJ0OyBqIDwgbWluKG4sIHN0YXJ0ICsgOTAwMCk7IGorKykgewoJCQkvLyBzID0gKHMgKyBhW2pdIDwgbW9kID8gcythW2pdIDogcythW2pdLW1vZCk7CgkJCXMgPSAocyArIGFbal0pICUgbW9kOwoJCX0KCX0KCWNvdXQgPDwgcyA8PCBlbmRsOwp9