#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long, vector<long long>, greater<long long>>
    minHeap;
const int INF = 1e9 + 9;
const long long LINF = 1e17 + 9;
const long long MD = 998244353;
inline long long po(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % MD;
    a = (a * a) % MD;
    b /= 2;
  }
  return ans;
}
const int N = 3e5 + 33;
long long n, m, k, t;
int arr[402];
string s;
int dp[402][402][402];
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cout << fixed;
  cout << setprecision(7);
  cerr << "N"
       << " is " << N << endl;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int l = 0; l < n; l++) {
    for (int r = l + 1; r < n; r++) {
      dp[l][r][0] = arr[r] - arr[l];
    }
  }
  for (int i = 1; i < n + 1; i++) {
    for (int l = 0; l < n; l++) {
      int j = l;
      for (int r = l + 1; r < n; r++) {
        int ans = max((int)dp[l][j][i - 1], arr[r] - arr[j]);
        while (j + 1 < n &&
               max((int)dp[l][j + 1][i - 1], arr[r] - arr[j + 1]) <= ans) {
          j++;
          ans = max((int)dp[l][j][i - 1], arr[r] - arr[j]);
        }
        dp[l][r][i] = ans;
      }
    }
  }
  long long ans = 0;
  while (m--) {
    int l, r, c, d;
    cin >> l >> r >> c >> d;
    ans = max(ans, 1ll * c * dp[l - 1][r - 1][d]);
  }
  cout << ans;
  return 0;
}
