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.*;
  import java.math.*;
  import java.text.*;
  
  public class Main {
      static PrintWriter out;
      static Reader in;
      static int nodes;
  
      public static void main(String[] args) throws IOException {
          initInputOutput();
          Main solver = new Main();
          solver.solve();
          out.close();
          out.flush();
      }
  
      static int n, maxN = (int)3e5;
  
      void solve() throws IOException {
      	n = in.nextInt();
  
          int[] arr = new int[n];
          for (int i = 0; i < n; i++) arr[i] = in.nextInt();
  
          Bit st = new Bit(maxN);
      	Bit cnt = new Bit(maxN);
      	long[] ans = new long[n];
  
      	long sum = 0;
      	for (int i = 0; i < n; i++) {
      		if (i != 0) ans[i] += ans[i-1];
      		ans[i] += sum + (long)i*arr[i];
  
      		ans[i] -= st.get(arr[i]);
  
      		for (int j = arr[i]; j <= maxN; j += arr[i]) {
      			int l = j, r = j+arr[i]-1;
      			st.update(l, arr[i]);
      			ans[i] -= cnt.query(l, Math.min(r, maxN))*j;
      		}
  
      		cnt.update(arr[i], 1);
      		sum += arr[i];
      	}
  
      	for (int i = 0; i < n; i++) out.print(ans[i]+" ");
      	out.println();
      }
  
      static class Bit {
      	long[] bit;
      	int n;
  
      	Bit(int n) {
      		this.n = n;
      		bit = new long[n+1];
      	}
  
      	public void update(int pos, long val) {
      		if (pos <= 0) return;
  
      		for (int i = pos; i <= n; i += i&-i) bit[i] += val;
      	}
  
      	public long get(int pos) {
      		long sum = 0;
      		for (int i = pos; i > 0; i -= i&-i) 
      			sum += bit[i];
  
      		return sum;
      	}
  
      	public long query(int l, int r) {
      		return get(r) - get(l-1);
      	}
      }
  
      static class Reader {
  
          private InputStream mIs;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
  
          public Reader() {
              this(System.in);
          }
  
          public Reader(InputStream is) {
              mIs = is;
          }
  
          public int read() {
              if (numChars == -1) {
                  throw new InputMismatchException();
  
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = mIs.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar++];
          }
  
          public String nextLine() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = read();
              } while (!isEndOfLine(c));
              return res.toString();
          }
  
          public String next() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          public long nextLong() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public int nextInt() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public boolean isSpaceChar(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          public boolean isEndOfLine(int c) {
              return c == '\n' || c == '\r' || c == -1;
          }
  
      }
      static void initInputOutput() throws IOException {
          // input
          File f = new File("in.txt");
          if (f.exists() && !f.isDirectory()) {
              in = new Reader(new FileInputStream("in.txt"));
          } else {
              in = new Reader();
          }
  
          // output
          f = new File("out.txt");
          if (f.exists() && !f.isDirectory()) {
              out = new PrintWriter(new File("out.txt"));
          } else {
              out = new PrintWriter(System.out);
          }
      }
  }