第三题100 Scanner s = new Scanner(System.in); int n = s.nextInt(); BigInteger[] a = new BigInteger[n]; for(int i = 0;i < n;i ++) a[i] = new BigInteger(s.next()); BigInteger sum = new BigInteger("0"); BigInteger cur = a[0]; BigInteger pre = a[0]; for(int i = 1;i < n;i ++) { sum = sum.add(cur.multiply(a[i])); pre = pre.add(a[i]); cur = cur.add(pre); } System.out.println(sum.mod(new BigInteger("1000000007")));