#include <bits/stdc++.h>
using namespace std;
const int maxn = 2.5e5 + 5;
long long a[405], s[maxn], f[maxn], c[maxn], r[maxn], p[maxn];
long long n, m, fuel, cnt, lo, hi, d, mid, ans;
long long check(long long ind, long long x) {
  fuel = x, cnt = 0;
  for (long long i = s[ind]; i < f[ind]; i++) {
    d = a[i + 1] - a[i];
    if (fuel < d * c[ind]) {
      cnt++;
      fuel = x;
    }
    if (fuel < d * c[ind]) return 0;
    fuel -= d * c[ind];
  }
  return cnt <= r[ind];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= m; i++) {
    cin >> s[i] >> f[i] >> c[i] >> r[i];
    p[i] = i;
  }
  random_shuffle(p + 1, p + m + 1);
  for (long long i = 1; i <= m; i++) {
    int ind = p[i];
    if (check(ind, ans)) continue;
    lo = ans, hi = 1e18;
    while (hi - lo > 1) {
      mid = (hi + lo) >> 1;
      if (check(ind, mid))
        hi = mid;
      else
        lo = mid;
    }
    ans = hi;
  }
  cout << ans << endl;
  return 0;
}
