#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int INF = 0x3f3f3f3f;
int dp[405][405], s[N], f[N], c[N], r[N], a[405], n, m;
long long ans;
vector<int> V[405];
int main() {
  scanf("%d %d", &n, &m);
  long long ans = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++)
    scanf("%d %d %d %d", &s[i], &f[i], &c[i], &r[i]), V[s[i]].push_back(i);
  for (int i = 1; i <= n; i++) {
    memset(dp, 0x3f, sizeof dp);
    dp[i][0] = 0;
    for (int j = i + 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (k == j - i)
          dp[j][k] = max(dp[j - 1][k - 1], a[j] - a[j - 1]);
        else if (k > j - i)
          dp[j][k] = dp[j][k - 1];
        else {
          int l = i + k - 1, r = j - 1, ans = -1;
          while (l <= r) {
            int mid = l + r >> 1;
            if (dp[mid][k - 1] >= a[j] - a[mid]) {
              ans = mid;
              r = mid - 1;
            } else
              l = mid + 1;
          }
          if (ans == -1)
            dp[j][k] = a[j] - a[j - 1];
          else
            dp[j][k] = dp[ans][k - 1];
          if (ans > i) dp[j][k] = min(dp[j][k], a[j] - a[ans - 1]);
        }
      }
    }
    for (auto it : V[i]) {
      long long sum;
      if (r[it] == 0)
        sum = (a[f[it]] - a[s[it]]) * 1ll * c[it];
      else if (r[it] >= f[it] - s[it])
        sum = dp[f[it]][r[it]] * 1ll * c[it];
      else {
        sum = INF;
        for (int j = s[it] + r[it]; j <= f[it]; j++) {
          sum = min(sum, 0ll + max(dp[j][r[it]], a[f[it]] - a[j]));
        }
        sum = sum * 1ll * c[it];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}
