#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector a(n), b(m), c(n); cin >> a >> b >> c; ll s = 0, ans = 1ll << 60; map mp; mp[a[0]] += c[0]; for(int i = 1; i < n; i++){ s += b[(i - 1) % m]; mp[a[i] - s] += c[i]; } s = accumulate(c.begin(), c.end(), 0ll); for(auto &&[key, v] : mp){ ans = min(ans, s - v); } cout << ans << '\n'; }