#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void debug(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void debug(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " | ";
  debug(comma + 1, args...);
}
const int INF = 1e9 + 5;
const int N = 400 + 5;
const int M = 1e6;
const long long oo = 1e18 + 5;
const int mod = 1e9 + 7;
int dp[N][N][N];
int sum[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      dp[i][j][0] = sum[i][j] = a[j] - a[i];
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int k = 1; k <= n; ++k) {
      int st = i;
      for (int j = i; j < n; ++j) {
        while (st + 1 <= j && sum[i][st + 1] <= dp[st + 1][j][k - 1]) ++st;
        dp[i][j][k] = max(sum[i][st], dp[st][j][k - 1]);
        if (st + 1 <= j) {
          dp[i][j][k] =
              min(dp[i][j][k], max(sum[i][st + 1], dp[st + 1][j][k - 1]));
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    --s, --f;
    ans = max(ans, 1ll * dp[s][f][r] * c);
  }
  cout << ans;
  return 0;
}
