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: /**
   * author: derrick20
   * created: 7/25/21 3:12 PM
   */
  import java.io.*;
  import java.util.*;
  import static java.lang.Math.*;
  
  public class F_PairwiseModulo {
      static FastScanner sc = new FastScanner();
      static PrintWriter out = new PrintWriter(System.out);
      
      public static void main(String[] args) {
          int MAX = (int) 3e5;
          int N = sc.nextInt();
          BIT pullContrib = new BIT(MAX);
          RangeBIT pushContrib = new RangeBIT(MAX);
          long pre = 0;
          long ans = 0;
          for (int i = 0; i < N; i++) {
              int a = sc.nextInt();
              long rightAmt = pre + (long) a * i;
              pre += a;
              rightAmt -= pushContrib.query(a) - pushContrib.query(a - 1);
              for (int b = a; b <= MAX; b += a) {
                  long blockCount = pullContrib.get(min(b + a - 1, MAX)) - pullContrib.get(b - 1);
                  rightAmt -= b * blockCount;
                  pushContrib.addRange(b, min(b + a - 1, MAX), b);
              }
              pullContrib.add(a, 1);
              ans += rightAmt;
              out.print(ans + " ");
          }
          out.println();
          out.close();
      }
  
      static class BIT {
          long[] tree;
          public BIT(int max) {
              tree = new long[max + 1];
          }
  
          public void add(int i, long delta) {
              while (0 < i && i < tree.length) {
                  tree[i] += delta;
                  i += i & -i;
              }
          }
  
          public long get(int i) {
              long ans = 0;
              while (i > 0) {
                  ans += tree[i];
                  i -= i & -i;
              }
              return ans;
          }
      }
  
      static class RangeBIT {
          long[] linearTree, constantTree;
          public RangeBIT(int max) {
              linearTree = new long[max + 1];
              constantTree = new long[max + 1];
          }
  
          public void add(boolean doLinear, int i, long delta) {
              long[] tree = doLinear ? linearTree : constantTree;
              if (i == 0) return;
              while (i < tree.length) {
                  tree[i] += delta;
                  i += i & -i;
              }
          }
  
          public void addRange(int l, int r, long delta) {
              if (l > r) return;
              add(true, l, delta);
              add(true, r + 1, -delta);
              add(false, l, delta * (-l + 1));
              add(false, r + 1, delta * r);
          }
  
          public long query(int i) {
              long constant = 0;
              long coeff = 0;
              int j = i;
              while (j > 0) {
                  constant += constantTree[j];
                  coeff += linearTree[j];
                  j -= j & -j;
              }
              return coeff * i + constant;
          }
      }
  
      static class FastScanner {
          private int BS = 1 << 16;
          private char NC = (char) 0;
          private byte[] buf = new byte[BS];
          private int bId = 0, size = 0;
          private char c = NC;
          private double cnt = 1;
          private BufferedInputStream in;
      
          public FastScanner() {
              in = new BufferedInputStream(System.in, BS);
          }
      
          public FastScanner(String s) {
              try {
                  in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
              } catch (Exception e) {
                  in = new BufferedInputStream(System.in, BS);
              }
          }
      
          char getChar() {
              while (bId == size) {
                  try {
                      size = in.read(buf);
                  } catch (Exception e) {
                      return NC;
                  }
                  if (size == -1) return NC;
                  bId = 0;
              }
              return (char) buf[bId++];
          }
      
          int nextInt() {
              return (int) nextLong();
          }
      
          long nextLong() {
              cnt = 1;
              boolean neg = false;
              if (c == NC) c = getChar();
              for (; (c < '0' || c > '9'); c = getChar()) {
                  if (c == '-') neg = true;
              }
              long res = 0;
              for (; c >= '0' && c <= '9'; c = getChar()) {
                  res = (res << 3) + (res << 1) + c - '0';
                  cnt *= 10;
              }
              return neg ? -res : res;
          }
      
          double nextDouble() {
              boolean neg = false;
              if (c == NC) c = getChar();
              for (; (c < '0' || c > '9'); c = getChar()) {
                  if (c == '-') neg = true;
              }
              double cur = nextLong();
              if (c != '.') {
                  return neg ? -cur : cur;
              } else {
                  double frac = nextLong() / cnt;
                  return neg ? -cur - frac : cur + frac;
              }
          }
      
          String next() {
              StringBuilder res = new StringBuilder();
              while (c <= 32) c = getChar();
              while (c > 32) {
                  res.append(c);
                  c = getChar();
              }
              return res.toString();
          }
      
          String nextLine() {
              StringBuilder res = new StringBuilder();
              while (c <= 32) c = getChar();
              while (c != '\n') {
                  res.append(c);
                  c = getChar();
              }
              return res.toString();
          }
      
          boolean hasNext() {
              if (c > 32) return true;
              while (true) {
                  c = getChar();
                  if (c == NC) return false;
                  else if (c > 32) return true;
              }
          }
      }
      
      static void ASSERT(boolean assertion, String message) {
          if (!assertion) throw new AssertionError(message);
      }
      
      static void ASSERT(boolean assertion) {
          if (!assertion) throw new AssertionError();
      }
  }