#include using namespace std; long long MOD = 1000000007; int MAX_N = 200000; int MAX_A = 1000000000; int main(){ //想定TLE2 (O(N^2)) long long N; cin >> N; assert(N >= 1); assert(N <= MAX_N); vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; assert(A[i] >= 0); assert(A[i] <= MAX_A); } vector S(N + 1, 0); for (int i = 0; i < N; i++){ S[i + 1] = S[i] + A[i]; if (S[i + 1] >= MOD){ S[i + 1] -= MOD; } } long long ans = 0; for (int i = 0; i < N; i++){ for (int j = i; j < N; j++){ ans += S[j + 1] - S[i] + MOD; while (ans >= MOD){ ans -= MOD; } } } cout << ans << endl; }