fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. long long n, a[100005], s = 0; cin >> n;
  7. for(int i = 0; i < n; i++){
  8. cin >> a[i];
  9. }
  10. for(int i = 0; i < n; i++){
  11. for(int j = i + 1; j < n; j++){
  12. s += a[i] * a[j] / __gcd(a[i], a[j]);
  13. }
  14. }
  15. cout << s;
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5320KB
stdin
5
10 7 4 3 3
stdout
247