using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;

namespace abc177_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);

      var mod = new Mod((int)1e9 + 7);

      var accSum = new long[N];

      for (int i = N - 1; i >= 0; i--)
      {
        if (i < N - 1) accSum[i] = accSum[i + 1];
        accSum[i] = mod.Add(accSum[i], A[i]);
      }

      var ans = 0L;

      for (int i = 0; i < N - 1; i++)
      {
        ans = mod.Add(ans, mod.Mul(A[i], accSum[i + 1]));
      }

      Console.WriteLine(ans);
    }
  }

  class Mod
  {
    public int N { get; }
    private readonly List<long> fac = new List<long>() { 1, 1 };
    private readonly List<long> inv = new List<long>() { 0, 1 };
    private readonly List<long> facInv = new List<long>() { 1, 1 };

    public Mod(int n) { N = n; }

    public long Add(long a, long b) => (a % N + b % N + N) % N;
    public long Sub(long a, long b) => Add(a, -b);
    public long Mul(long a, long b) => (a % N * b % N + N) % N;
    public long Div(long a, long b) => Mul(a, Inv(b));

    public long Inv(long a)
    {
      if (a < inv.Count) return inv[(int)a];
      long b = N, x = 1, y = 0, tmp;
      while (b != 0)
      {
        var q = a / b;
        tmp = y;
        y = x - q * y;
        x = tmp;
        tmp = b;
        b = a - q * b;
        a = tmp;
      }
      return (x % N + N) % N;
    }

    public long Pow(long a, long n)
    {
      var result = 1L;
      while (n > 0)
      {
        if ((n & 1) == 1) result = Mul(result, a);
        a = Mul(a, a);
        n >>= 1;
      }
      return result;
    }

    public void InitSeq(int n)
    {
      for (var i = fac.Count; i <= n; i++)
      {
        fac.Add(fac[i - 1] * i % N);
        inv.Add(N - inv[N % i] * (N / i) % N);
        facInv.Add(facInv[i - 1] * inv[i] % N);
      }
    }

    public long Fac(int n)
    {
      InitSeq(n);
      return fac[n];
    }

    public long Per(int n, int k)
    {
      if (n < k || n < 0 || k < 0) return 0;
      InitSeq(n);
      return fac[n] * facInv[n - k] % N;
    }

    public long Com(int n, int k)
    {
      if (n < k || n < 0 || k < 0) return 0;
      InitSeq(n);
      return fac[n] * (facInv[k] * facInv[n - k] % N) % N;
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 51496