description: You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \ldots, p_n$$$. 
  
  Input
  
  The first line contains n — the length of the array (2 ≤ n ≤ 2 ⋅ 10^5).
  
  The second line contains n space-separated distinct integers a_1, …, a_n (1 ≤ a_i ≤ 3 ⋅ 10^5, a_i ≠ a_j if i ≠ j). 
  
  Output
  
  Print n integers p_1, p_2, …, p_n. 
  
  Examples
  
  Input
  
  
  4
  6 2 7 3
  
  
  Output
  
  
  0 2 12 22
  
  
  Input
  
  
  3
  3 2 1
  
  
  Output
  
  
  0 3 5
solution: import java.io.*;
  import java.util.*;
  
  import static java.lang.Math.max;
  import static java.lang.Math.min;
  
  public class Current {
      FastScanner in;
      PrintWriter out;
  
      class Fenwick {
          int n;
          long[] a;
  
          Fenwick(int n) {
              this.n = n;
              a = new long[n + 1];
          }
  
          void add(int i, long x) { // 1-indexing
              while (i <= n) {
                  a[i] += x;
                  i = (i | (i - 1)) + 1;
              }
          }
  
          long prefSum(int i) { // 1-indexing
              long sum = 0;
              while (i > 0) {
                  sum += a[i];
                  i = i & (i - 1);
              }
              return sum;
          }
  
          long segSum(int l, int r) {
              return prefSum(r) - prefSum(l - 1);
          }
      }
  
      private void solve() throws IOException {
          int n = in.nextInt(), maxA = (int) 3e5;
          int[] a = new int[n + 1];
          for (int i = 1; i <= n; i++)
              a[i] = in.nextInt();
  
          long pk = 0, prefSum = 0;
          Fenwick cntValue = new Fenwick(maxA);
          Fenwick cnt = new Fenwick(maxA);
  
          for (int k = 1; k <= n; k++) {
              pk += (long) a[k] * (k - 1);
              pk -= cntValue.prefSum(a[k]);
              for (int i = a[k]; i <= maxA; i += a[k])
                  cntValue.add(i, a[k]);
  
              pk += prefSum;
              prefSum += a[k];
              for (int l = 0; l <= maxA; l += a[k])
                  pk -= (long) l * cnt.segSum(l, min(maxA, l + a[k] - 1));
              cnt.add(a[k], 1);
  
              out.print(pk + (k == n ? "" : " "));
          }
          out.println();
      }
  
      class FastScanner {
          StringTokenizer st;
          BufferedReader br;
  
          FastScanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          long nextLong() throws IOException {
              return Long.parseLong(next());
          }
      }
  
      private void run() throws IOException {
          in = new FastScanner(System.in);
          out = new PrintWriter(System.out);
  
          for (int t = 1 /* in.nextInt() */; t-- > 0; )
              solve();
  
          out.flush();
          out.close();
      }
  
      public static void main(String[] args) throws IOException {
          new Current().run();
      }
  }
  