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.util.*;
  import java.io.*;
  
  public class Harbour2022 {
      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////                                                                                                               /////////
  ////////                                                                                                               /////////
  ////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
  ////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMMMM      MMMMMM      OOO      OOO        SSSS   SSS     EEEEEEEEEEEEE  /////////
  ////////   HHHH        HHHH  EEEEE           MMMM MMM  MMM MMMM    OOO          OOO    SSSS       SSS   EEEEE          /////////
  ////////   HHHH        HHHH  EEEEE           MMMM  MMMMMM  MMMM   OOO            OOO   SSSS             EEEEE          /////////
  ////////   HHHH        HHHH  EEEEE           MMMM          MMMM  OOO              OOO   SSSSSSS         EEEEE          /////////
  ////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO      SSSSSS       EEEEEEEEEEE    /////////
  ////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO         SSSSSSS   EEEEEEEEEEE    /////////
  ////////   HHHH        HHHH  EEEEE           MMMM          MMMM   OOO            OOO              SSSS  EEEEE          /////////
  ////////   HHHH        HHHH  EEEEE           MMMM          MMMM    OOO          OOO     SSS       SSSS  EEEEE          /////////
  ////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM      OOO      OOO        SSS    SSSS    EEEEEEEEEEEEE  /////////
  ////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
  ////////                                                                                                               /////////
  ////////                                                                                                               /////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      static boolean[] vis;
  
      static int dfs(int idx, int[] edgs) {
          vis[idx] = true;
  
          int ans = 1;
          if (!vis[edgs[idx]])
              ans += dfs(edgs[idx], edgs);
  
          return ans;
      }
  
      static int solve(int[] a) {
          int n = a.length;
          vis = new boolean[n];
          int ans = 0;
          for (int i = 0; i < n; i++) {
              if (!vis[i])
                  ans += dfs(i, a) - 1;
          }
  
          return ans;
      }
  
      static int[] shift(int[] a, int v) {
          int[] res = new int[a.length];
  
          for (int i = 0; i < a.length; i++) {
              res[i] = a[(i + v) % a.length];
          }
          return res;
      }
  
      public static void main(String[] args) throws IOException {
          Scanner sc = new Scanner(System.in);
          PrintWriter pw = new PrintWriter(System.out);
          int n = sc.nextInt();
  
          int[] a = sc.nextIntArr(n);
  
          long[] sum = new long[n];
          long pre = 0;
  
          FenwickTree grtr = new FenwickTree(3 * 1000 * 100 + 10);
          FenwickTree count = new FenwickTree(3 * 1000 * 100 + 10);
  
          for (int i = 0; i < n; i++) {
              pre += a[i];
              count.point_update(a[i], 1);
              int cur = a[i];
              while (cur <= 3 * 1000 * 100) {
                  grtr.point_update(cur, a[i]);
                  sum[i] -= (1l * a[i] * count.rsq(cur, (int) 3e5));
                  cur += a[i];
              }
              sum[i] += pre;
              sum[i] += 1l * (i + 1) * a[i];
              sum[i] -= grtr.rsq(a[i]);
  //            sum[i] += 1l * count.rsq(a[i] + 1, (int) 3e5) * a[i];
              if (i > 0)
                  sum[i] += sum[i - 1];
              pw.print(sum[i] + " ");
          }
          pw.println();
  
  
          pw.flush();
      }
  
      static class FenwickTree { // one-based DS
  
          int n;
          long[] ft;
  
          FenwickTree(int size) {
              n = size;
              ft = new long[n + 1];
          }
  
          long rsq(int b) //O(log n)
          {
              long sum = 0;
              while (b > 0) {
                  sum += ft[b];
                  b -= b & -b;
              }        //min?
              return sum;
          }
  
          long rsq(int a, int b) {
              return rsq(b) - rsq(a - 1);
          }
  
          void point_update(int k, long val)    //O(log n), update = increment
          {
              while (k <= n) {
                  ft[k] += val;
                  k += k & -k;
              }        //min?
          }
  
      }
  
  
      static class Scanner {
          StringTokenizer st;
          BufferedReader br;
  
          public Scanner(FileReader r) {
              br = new BufferedReader(r);
          }
  
          public Scanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          public String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          public int[] nextIntArr(int n) throws IOException {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) {
                  a[i] = nextInt();
              }
              return a;
          }
  
          public int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          public long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          public String nextLine() throws IOException {
              return br.readLine();
          }
  
          public double nextDouble() throws IOException {
              String x = next();
              StringBuilder sb = new StringBuilder("0");
              double res = 0, f = 1;
              boolean dec = false, neg = false;
              int start = 0;
              if (x.charAt(0) == '-') {
                  neg = true;
                  start++;
              }
              for (int i = start; i < x.length(); i++)
                  if (x.charAt(i) == '.') {
                      res = Long.parseLong(sb.toString());
                      sb = new StringBuilder("0");
                      dec = true;
                  } else {
                      sb.append(x.charAt(i));
                      if (dec)
                          f *= 10;
                  }
              res += Long.parseLong(sb.toString()) / f;
              return res * (neg ? -1 : 1);
          }
  
          public boolean ready() throws IOException {
              return br.ready();
          }
      }
  
  }