import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] m = new int[n]; for(int m_i=0; m_i < n; m_i++){ m[m_i] = in.nextInt(); } long e = 1000000007; int res = 0; if(n%2 == 0){ res = (n*(n-1))/2; } else res = ((n-1)*(n+1))/2; System.out.println(res%e); // your code goes here } }