Guest User

Untitled

a guest
May 23rd, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define M 1000000007
  4. int main()
  5. {
  6. long long var,sum=0;
  7. cin>>var;
  8. vector <long long> v;
  9. long long a[var];
  10. for(long long i=0;i<var;i++)
  11. cin>>a[i];
  12. sort(a,a+var);
  13. for(long long i=0;i<(1<<var);i++)
  14. {
  15. for(long long j=0;j<var;j++)
  16. if(i & (1<<j))
  17. v.push_back(a[j]%M);
  18. if(v.size() > 1)
  19. sum = (sum%M + v[v.size() -1]%M - v[0]%M)%M;
  20. v.clear();
  21. }
  22. cout<<sum%M;
  23. return 0;
  24. }
Add Comment
Please, Sign In to add comment